-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
executable file
·60 lines (49 loc) · 1.69 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
// dependecies
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var mongoose = require('mongoose');
var nodemon = require('nodemon');
var path = require('path');
var stripe = require("stripe")("sk_test_Ny38x1Z7YQaYzmFq0YwMPP2w");
var schedule = require('node-schedule');
var session = require('express-session');
var systemController = require('./controllers/systemController');
var passport = require('passport');
var flash = require('connect-flash');
var Booking = require('./models/Booking');
var Arena = require('./models/Arena');
var logger = require('morgan');
var validator = require('express-validator');
var serviceProviderController = require('./controllers/serviceProviderController');
schedule.scheduleJob({ hour: 07, minute: 00, dayOfWeek: 6 }, systemController.updateSchedule);
var router = require('./routes/router');
//database connection url
var db_url = "mongodb://localhost:27017/db";
mongoose.Promise = Promise;
app.use(logger('dev'));
// config app
app.set('view engine', 'ejs');
app.set('views', path.resolve(__dirname, 'views'));
mongoose.connect(db_url);
app.use(express.static(path.resolve(__dirname, './public')));
app.use(bodyParser.urlencoded({ extended: false , limit: 300*1024}));
app.use(validator());
app.use(cookieParser());
app.use(session({
secret: "TKR]s$s,<<MXv0#&!F!%IWw/4KiVJs=HYqrvagQV",
resave: true,
saveUninitialized: true
}));
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use(logger('short'));
// stripe specific routes
app.use(router);
//router
//start server
app.listen(8080, function () {
console.log("app listening on port 8080");
});