-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
104 lines (70 loc) · 2.51 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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var express = require("express");
var app = express();
var bodyParser = require("body-parser");
var mongoose = require("mongoose");
var methodOverride = require("method-override");
var passport = require("passport");
var LocalStrategy = require("passport-local");
var passportLocalMongoose = require("passport-local-mongoose");
var request = require("request");
var dotenv = require("dotenv");
const connectdb=require('./config/setup');
dotenv.config({
path:'./config/.env'
});
connectdb();
var loginRouter = require('./routes/login');
var signupRouter = require('./routes/register');
var adminRouter = require('./routes/admin');
var addProfileRouter = require('./routes/addProfile');
const User = require("./models/user")
app.set("view engine", "ejs");
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended: true}));
app.use(methodOverride("_method"));
//mongoose.connect("mongodb://localhost/form_builder");
app.use(require("express-session")({
secret: "Anjaneya Tripathi",
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
passport.use(new LocalStrategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
var logout = require("./routes/logout");
app.use('/logout', logout);
var profileroute = require("./routes/profile");
app.use('/profile', profileroute);
var home = require("./routes/home");
app.use('/home', home);
var cartroute = require("./routes/cart");
app.use('/cart', cartroute)
var detailsroute = require("./routes/detail");
app.use('/details', detailsroute)
var addprofileroute = require("./routes/addProfile2");
app.use('/addProfile', addprofileroute)
var billsroute = require("./routes/bill");
app.use('/bill', billsroute)
var historyroute = require("./routes/history");
app.use('/history', historyroute)
var orderroute = require("./routes/orders");
app.use('/orders', orderroute)
var warehouseroute = require("./routes/warehouse");
app.use('/warehouse', warehouseroute)
var pendingorderroute = require("./routes/pendingorders");
app.use('/pendingOrders', pendingorderroute)
var updateroute = require("./routes/update");
app.use('/update', updateroute)
app.use('/login', loginRouter);
app.use('/register', signupRouter);
app.use('/admin', adminRouter);
app.use('/addProfile', addProfileRouter);
app.get('/', function(req, res) {
res.redirect('/login');
});
const port = process.env.PORT || 3000;
app.listen(port, function() {
console.log("Listening on port 80");
});