-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
40 lines (31 loc) · 1.02 KB
/
Copy pathapp.ts
File metadata and controls
40 lines (31 loc) · 1.02 KB
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
32
33
34
35
36
37
38
39
40
import express from 'express';
import cors from 'cors';
import * as winston from 'winston';
import * as expressWinston from 'express-winston';
import {Routes} from './src/services/routes';
import {CompanyRoutes} from './src/controllers/company';
const app: express.Application = express();
const port = 3000;
const routes: Array<Routes> = [];
app.use(cors());
app.use(express.json());
const loggerOptions: expressWinston.LoggerOptions = {
transports: [new winston.transports.Console()],
format: winston.format.combine(
winston.format.json(),
winston.format.prettyPrint(),
winston.format.colorize({ all: true })
),
};
if (!process.env.DEBUG) {
loggerOptions.meta = false;
}
app.use(expressWinston.logger(loggerOptions));
routes.push(new CompanyRoutes(app));
const runningMessage = `Server running at http://localhost:${port}`;
app.get('/', (req: express.Request, res: express.Response) => {
res.status(200).send(runningMessage)
});
app.listen(port, () => {
console.log(runningMessage);
});