-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
58 lines (52 loc) · 2.22 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
const express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
//const methodOverride = require('method-override');
const session = require('express-session');
const app = express();
const mysql = require('mysql');
let bodyParser=require("body-parser");
let connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'movielist'
});
connection.connect();
global.db = connection;
// all environments
app.set('port', process.env.PORT || 8080);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(express.static('public'))
// app.use(express.static(path.join(__dirname, 'public')));
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
cookie: { maxAge: 3600000 }
}))
// development only
app.get('/', routes.index);//call for main index page
app.get('/signup', user.signup);//call for signup page
app.post('/signup', user.signup);//call for signup post
app.get('/login', routes.index);//call for login page
app.post('/login', user.login);//call for login post
app.get('/home/dashboard', user.dashboard);//call for dashboard page after login
app.get('/home/logout', user.logout);//call for logout
app.get('/home/profile',user.profile);//to render users profile
app.get('/home/list',user.list);//to render users movie list
app.get('/home/list/sort',user.sort);//to render users movie list sort
app.get('/home/wishlist',user.wishlist);//to render users wishlist
app.get('/home/list/details/:id',user.details);//to render users movie details
app.get('/home/list/deletemovie/:id',user.deletemovie);//delete
app.get('/home/list/editmovie/:id',user.editmovie);//to render users edit movie
app.get('/home/list/addmovie',user.addmovie);//to render users add movie
app.post('/home/list/addmovie',user.addmovie);//to render users addmovie
app.post('/home/list/updatemovie/:id',user.updatemovie);//to render users update
//Middleware
app.listen(8080)