-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
24 lines (24 loc) · 869 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
import express from "express";
import path from "path";
import cookieParser from 'cookie-parser'
import dotenv from "dotenv";
import "./configs/db";
import allRoutes from "./routes/main";
import notFoundMiddlewares from './middlewares/notFound'
import errorsMiddlewares from './middlewares/errors'
import cors from 'cors'
import corsOptions from "./configs/corsOptions";
import credentialMiddlewares from "./middlewares/credential";
dotenv.config();
const app = express();
const port = process.env.PORT || 4000;
app.use(credentialMiddlewares)
app.use(cors(corsOptions))
app.use(express.static(path.join(__dirname, "public")));
app.use(express.urlencoded({extended:false}))
app.use(express.json());
app.use(cookieParser())
app.use(allRoutes);
app.use(notFoundMiddlewares)
app.use(errorsMiddlewares)
app.listen(port, () => console.log(`Server running on port ${port}`));