-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.ts
More file actions
31 lines (25 loc) · 895 Bytes
/
index.ts
File metadata and controls
31 lines (25 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* eslint-disable import/first */
import http from 'http';
import express from 'express';
import log4js from 'log4js';
import mongoose from 'mongoose';
import { Server } from 'socket.io';
const app = express();
const server = http.createServer(app);
globalThis.io = new Server(server);
// eslint-disable-next-line
import { CustomError } from './services';
globalThis.CustomError = CustomError;
import { db, files, port } from './configs';
import routers from './routers';
const logger = log4js.getLogger('ENTRY.index');
(async () => {
if (db.uri) {
await mongoose.connect(db.uri);
}
})();
// you can specify a path `${origin}/yourPath` or by default it's `${origin}`
app.use(express.static(files));
app.use('/', routers);
app.set('view engine', 'ejs'); // by default ejs files in root's 'views' directory
server.listen(port, () => logger.info(`app listen ${port} port`));