forked from ogabriel/APS-UNIP-8sem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (33 loc) · 940 Bytes
/
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
'use strict';
// Config envs
require('dotenv').config();
// Configure express
const path = require('path');
const express = require('express');
const session = require('express-session');
const methodOverride = require('method-override');
const passport = require('passport');
const app = express();
// Configure json
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Configure DELETE and PUT on forms
app.use(methodOverride('_method'));
// Configure session
app.use(
session({
secret: process.env.SESSION_SECRET || 'aps8',
resave: false,
saveUninitialized: true,
})
);
// Passport middleware
app.use(passport.initialize());
app.use(passport.session());
// Config static files
app.use(express.static(path.join(__dirname, 'public')));
// Config api routes
const routes = require(path.join(process.cwd(), 'config/routes'));
app.use('/', routes);
// Exports whole app
module.exports = app;