-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
64 lines (51 loc) · 1.51 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var express = require("express");
const path = require("path");
const mongoose = require("mongoose");
const bodyparser = require("body-parser");
const passport = require("passport");
/**
*ROLE ID :
Admin - 2
User - 1
*/
const app = express();
const port = 3500 || process.env.PORT;
//Passport Middleware
app.use(passport.initialize());
require("./strategy/jsonwtStrategy")(passport);
// app.use(express.static(path.join(__dirname, "public")));
// app.set("view engine", "ejs");
app.use(bodyparser.urlencoded({ extended: false }));
app.use(bodyparser.json());
// Importing all the routes/api
const auth = require("./routes/api/auth");
const booking = require("./routes/api/booking");
const flight = require("./routes/api/flight");
app.use("/auth", auth);
app.use("/booking", booking);
app.use("/flight", flight);
var db = require("./setup/DBSetup").DBURL;
var usernameDB=require('./setup/DBSetup').username;
var passwordDB=require('./setup/DBSetup').password;
const authData = {
user: usernameDB,
pass: passwordDB,
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true
};
mongoose
.connect(db, authData)
.then(() => console.log("MongoDB Connected"))
.catch(err => console.log("MongoDB Connection Error " + err));
//Basic Checking of Server
app.get("/", (req, res) => {
res.send("<p>Airticket Server :)</p>");
});
app.get("/test", (req, res) => {
res.send("<p>This is test from Rohan</p>");
});
//Starting Server
app.listen(port, () => {
console.log(`Server started on ${port}`);
});