refactor: app in html

This commit is contained in:
cha0s 2020-07-12 18:44:00 -05:00
parent 7b69d023e6
commit 8c8c879283
2 changed files with 10 additions and 21 deletions

View File

@ -1,15 +0,0 @@
import express from 'express';
import userRoutes from './routes/user';
import passport from './passport';
import session from './session';
export default function createApp() {
const app = express();
app.use(express.urlencoded({extended: true}));
app.use(session());
app.use(passport.initialize());
app.use(passport.session());
userRoutes(app);
return app;
}

View File

@ -1,16 +1,20 @@
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
import express from 'express'; import express from 'express';
import http, {ServerResponse} from 'http'; import http, {ServerResponse} from 'http';
import httpProxy from 'http-proxy';
import {join} from 'path'; import {join} from 'path';
import httpProxy from 'http-proxy'; import userRoutes from './routes/user';
import passport from './passport';
import createApp from './app'; import session from './session';
let app;
export function createHttpServer() { export function createHttpServer() {
app = createApp(); const app = express();
app.use(express.urlencoded({extended: true}));
app.use(session());
app.use(passport.initialize());
app.use(passport.session());
userRoutes(app);
const httpServer = http.createServer(app); const httpServer = http.createServer(app);
httpServer.listen(31344, '0.0.0.0'); httpServer.listen(31344, '0.0.0.0');
if ('production' !== process.env.NODE_ENV) { if ('production' !== process.env.NODE_ENV) {