-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (28 loc) · 993 Bytes
/
index.js
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
import express from "express"
import {connect} from "./backend/src/database/config.js"
import logger from "./backend/src/middlewares/looger.middleware.js"
import bodyParser from "body-parser";
import { errorHandler } from "./backend/src/middlewares/error.middleware.js";
import ejsLayout from "express-ejs-layouts";
import path from "path";
import view from "./frontend/src/view.router.js"
import cookieParser from "cookie-parser";
import dotenv from "dotenv";
import backend from "./backend/backend.router.js";
const app=express();
dotenv.config();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
app.use(cookieParser());
app.use(logger);
app.use(ejsLayout);
app.set('view engine','ejs');
app.set('views',path.resolve("frontend","views"));
app.use(express.static("public"));
app.use("/api",backend);
app.use("/",view);
app.use(errorHandler);
app.listen(process.env.PORT,()=>{
console.log("server is started at the",process.env.PORT);
connect();
})