-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
35 lines (27 loc) · 735 Bytes
/
Copy pathApp.js
File metadata and controls
35 lines (27 loc) · 735 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
30
31
32
33
34
35
import express from 'express';
import env from 'dotenv';
import DBconnect from "./db/mongoDBConnection.js";
import router from "./routes/Routes.js";
import bcrypt from "bcrypt";
import jwt from "jsonwebtoken";
import cookieParser from "cookie-parser";
env.config();
const PORT = process.env.PORT || 3000;
const app = express();
app.set("view engine", "ejs");
//middlewares
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static( 'public'));
app.use(cookieParser());
// Routes
app.use("/", router);
app.listen(PORT, async ()=>{
try{
await DBconnect();
console.log("Server started on port: " + PORT);
}
catch(err){
console.log(err.message);
}
});