-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (23 loc) · 763 Bytes
/
app.js
File metadata and controls
29 lines (23 loc) · 763 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
import './database/db';
import express from 'express';
import bodyParser from 'body-parser';
import routes from './routes';
import cors from 'cors';
import cookieParser from 'cookie-parser';
import { handleError, logger } from './middlewares';
import passport from './controller/passportControllers';
import { API_PORT, hosts } from './env';
const app = express();
app.use(cors({ origin: hosts, credentials: true }));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(passport.initialize());
app.use(passport.session());
routes(app);
app.use((err, _req, res, _) => {
handleError(err, res);
});
app.listen(API_PORT, () => {
logger.info(`Api listening on port ${Number(API_PORT)}!`);
});