forked from babuldebbarma/Swaggy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (35 loc) · 963 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
37
38
39
40
41
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const path = require("path");
const expressValidator = require("express-validator");
const config = require("./config.json");
const passport = require("passport");
mongoose.connect(
config.databaseUrl,
err => {
if (err) {
throw err;
}
console.log("Node Server Connected to Mongo Database");
}
);
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(expressValidator());
app.use(passport.initialize());
app.use(passport.session());
app.use(function(req, res, next) {
res.locals.user = req.user;
next();
});
const customerroutes = require("./routes/customer");
app.use("/customer", customerroutes);
const port = process.env.port || 1234;
app.listen(port, err => {
if (err) {
throw err;
}
console.log(`Server Running at port number ${port}`);
});