-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (29 loc) · 878 Bytes
/
server.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
let express = require("express");
const app = express();
const mongoose = require("mongoose")
require("dotenv").config();
const bodyParser = require("body-parser");
const expressLayouts = require("express-ejs-layouts");
app.set("view engine" , "ejs");
app.set('views', __dirname + '\\views');
app.use(bodyParser.json());
app.use(express.static(__dirname + "/scripts"));
app.use(bodyParser.urlencoded({
extended: true
}))
// app.use(expressLayouts);
// app.get("/" , (req ,res) => {
// res.render("index");
// })
mongoose.connect(process.env.DATABASE_URL ,{useNewUrlParser : true} ).then(() => {
console.log("mongoose connected");
}).catch((error) => {console.log(error);});
app.listen(3000 , (err , res) => {
if (err){
console.log(err);
}
else {
console.log("listening on port 3000");
}
})
app.use("/" , require("./router"));