-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (28 loc) · 1.12 KB
/
app.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
const express = require("express"),
app = express(),
bodyparser = require("body-parser"),
mongoose = require("mongoose"),
methodOverride = require("method-override"),
middleware = require("./middleware/index");
seed = require("./seed");
require("dotenv").config();
//ROUTES
const campgroundRoute = require("./routes/campgrounds"),
commentRoute = require("./routes/comments"),
indexRoute = require("./routes/index"),
userRoute = require("./routes/user");
mongoose.connect(process.env.DATABASEURL,{useUnifiedTopology: true, useNewUrlParser:true});
mongoose.set('useFindAndModify', false);
mongoose.set('useCreateIndex', true);
app.use(bodyparser.urlencoded({extended:true}));
app.set("view engine","ejs");
app.use(methodOverride("_method"));
middleware(app);
app.use("/campground",campgroundRoute);
app.use("/campground/:id/comments",commentRoute);
app.use("/",indexRoute);
app.use("/user",userRoute);
app.listen(process.env.PORT || 3000)
{
console.log("Server has started");
};