|
@@ -1,38 +1,31 @@
|
|
|
-//import express from "express"
|
|
|
+const db = require('./db')
|
|
|
+const pg = require('pg')
|
|
|
+delete pg.native
|
|
|
|
|
|
-const PORT = process.env.PORT || 3500;
|
|
|
-//const URL = ["http://localhost:3050"];
|
|
|
-
|
|
|
-const express = require("express")
|
|
|
-const app = express();
|
|
|
-
|
|
|
- const server = app.listen(PORT, () => {
|
|
|
- console.log(chalk.blue(`[Express] Listening on port ${PORT}`));
|
|
|
- });
|
|
|
-
|
|
|
-const socketio = require("socket.io");
|
|
|
-const io = socketio(server);
|
|
|
-require("./socket")(io);
|
|
|
-
|
|
|
-
|
|
|
-const path = require("path");
|
|
|
+const express = require('express')
|
|
|
+const app = express()
|
|
|
+const path = require('path')
|
|
|
+const morgan = require('morgan')
|
|
|
+const socketio = require('socket.io')
|
|
|
|
|
|
//const cors = require("cors");
|
|
|
-const morgan = require("morgan");
|
|
|
-
|
|
|
-const pg = require("pg");
|
|
|
-delete pg.native;
|
|
|
-const db = require("./db");
|
|
|
-const chalk = require("chalk");
|
|
|
-
|
|
|
//const passport = require('passport')
|
|
|
//const LocalStrategy = require('passport-local')
|
|
|
//const session = require('express-session')
|
|
|
//const SequelizeStore = require('connect-session-sequelize')(session.Store)
|
|
|
//const sessionStore = new SequelizeStore({ db })
|
|
|
-//const bot = require('../ircbot')
|
|
|
|
|
|
-app.use(morgan("dev"));
|
|
|
+const PORT = process.env.PORT || 3500
|
|
|
+//const URL = ["http://localhost:3050"];
|
|
|
+
|
|
|
+const server = app.listen(PORT, () => {
|
|
|
+ console.log(`[Express] Listening on port ${PORT}`)
|
|
|
+})
|
|
|
+
|
|
|
+const io = socketio(server)
|
|
|
+require('./socket')(io)
|
|
|
+
|
|
|
+app.use(morgan('dev'))
|
|
|
//app.use(cors({ credentials: true, origin: URL }))
|
|
|
// passport.use(
|
|
|
// new LocalStrategy(async (username, password, done) => {
|
|
@@ -82,39 +75,38 @@ app.use(morgan("dev"));
|
|
|
// app.use(passport.session())
|
|
|
|
|
|
// body parsing middleware
|
|
|
-app.use(express.json());
|
|
|
-app.use(express.urlencoded({ extended: true }));
|
|
|
-app.use(require("body-parser").text());
|
|
|
+app.use(express.json())
|
|
|
+app.use(express.urlencoded({ extended: true }))
|
|
|
+app.use(require('body-parser').text())
|
|
|
//app.use("/api", require("./api"));
|
|
|
//app.use('/auth', require('./auth'))
|
|
|
app.use(
|
|
|
- "/static",
|
|
|
- express.static(path.resolve(__dirname, "..", "build", "static"))
|
|
|
-);
|
|
|
-app.get("/manifest.json", (req:any, res:any) => {
|
|
|
- res.sendFile(path.resolve(__dirname, "..", "build", "manifest.json"));
|
|
|
-});
|
|
|
-app.get("/favicon.png", (req:any, res:any) => {
|
|
|
- res.sendFile(path.resolve(__dirname, "..", "build", "favicon.png"));
|
|
|
-});
|
|
|
-app.use("*", express.static(path.resolve(__dirname, "..", "build")));
|
|
|
+ '/static',
|
|
|
+ express.static(path.resolve(__dirname, '..', 'build', 'static'))
|
|
|
+)
|
|
|
+app.get('/manifest.json', (req: any, res: any) => {
|
|
|
+ res.sendFile(path.resolve(__dirname, '..', 'build', 'manifest.json'))
|
|
|
+})
|
|
|
+app.get('/favicon.png', (req: any, res: any) => {
|
|
|
+ res.sendFile(path.resolve(__dirname, '..', 'build', 'favicon.png'))
|
|
|
+})
|
|
|
+app.use('*', express.static(path.resolve(__dirname, '..', 'build')))
|
|
|
|
|
|
// error handling endware
|
|
|
-app.use((err :any, req:any, res:any, next:any) => {
|
|
|
- console.error(err);
|
|
|
- console.error(err.stack);
|
|
|
- res.status(err.status || 500).send(err.message || "Internal server error.");
|
|
|
- next();
|
|
|
-});
|
|
|
+app.use((err: any, req: any, res: any, next: any) => {
|
|
|
+ console.error(err)
|
|
|
+ console.error(err.stack)
|
|
|
+ res.status(err.status || 500).send(err.message || 'Internal server error.')
|
|
|
+ next()
|
|
|
+})
|
|
|
|
|
|
-const startListening = () => {
|
|
|
-};
|
|
|
+const startListening = () => {}
|
|
|
|
|
|
const startApp = async () => {
|
|
|
//await sessionStore.sync();
|
|
|
- await startListening();
|
|
|
-};
|
|
|
+ await startListening()
|
|
|
+}
|
|
|
|
|
|
-startApp();
|
|
|
+startApp()
|
|
|
|
|
|
module.exports = {}
|