-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.ts
30 lines (23 loc) · 870 Bytes
/
app.ts
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
import express, { type Application } from 'express';
import NotFoundHandler from '@exceptions/not-found.handler.js';
import AllExceptionHandler from '@exceptions/all-exception.handler.js';
import ConnectedToMongodb from '@configs/mongodb.config.js';
import { setupRoutes } from './src/index.routes.js';
import logger from '@common/configs/logger.config.js';
const app: Application = express();
const port = process.env.PORT;
const uri = process.env.MONGODB_URI;
const database = process.env.MONGODB_DATABASE;
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use((req, res, next) => {
logger.info(`Request received: ${req.method} ${req.url}`);
next();
});
ConnectedToMongodb(uri, database);
setupRoutes(app);
NotFoundHandler(app);
AllExceptionHandler(app);
app.listen(port, () => {
console.log(`server run on port ${port}`);
});