-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.js
62 lines (55 loc) · 1.96 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
const express = require('express');
const app = express();
const port = 8000;
const layouts = require('express-ejs-layouts');
const mongoose = require('./config/mongoose');
const bodyParser = require('body-parser');
const db = require('./config/mongoose');
const session = require('express-session');
const passport = require('passport');
const passportLocal = require('./config/passport');
const passportJwt = require('./config/jwt-passport-strategy');
const googlePassport = require('./config/passport-google-oauth2');
const mongoStore = require('connect-mongo');
const sassMiddleware = require('node-sass-middleware');
const path = require('path')
app.use(sassMiddleware({
/* Options */
src: path.join(__dirname, 'assets', 'scss')
, dest: path.join(__dirname, 'assets', 'css')
, debug: true
, outputStyle: 'extended'
, prefix: '/css'
}));
// app.use(bodyParser.urlencoded({ extended: false }))
app.use(express.urlencoded({extended:false}));
//Using Express-ejs-layout feature
app.use(layouts);
// extract style and scripts from sub pages into the layout
app.set('layout extractStyles', true);
app.set('layout extractScripts', true);
app.set('view engine', 'ejs');
app.set('views', './views');
app.use(session({
name: 'Google_Contacts',
// TODO change the secret before deployment in production mode
secret: '12346',
saveUninitialized: false,
resave: false,
cookie: {
maxAge: (1000 * 60 * 100)
},
store: mongoStore.create({
mongoUrl: db._connectionString,
autoRemove: 'disabled'
})
}));
app.use(express.static('assets'));
app.use('/uploads',express.static(__dirname+'/uploads'));
app.use(passport.initialize());
app.use(passport.session());
app.use(passport.setAuthenticatedUser);
app.use('/',require('./routes'));
app.listen(port,()=>{
console.log(`App Running on port: ${port}`);
})