-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
50 lines (40 loc) · 1.15 KB
/
index.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
require('dotenv').config();
const express = require('express');
const session = require('express-session');
const app = express();
const helmet = require('helmet');
const path = require('path');
const PORT = process.env.PORT || 3000;
const logger = require('morgan');
// NOTE DB model setting
const db = require('./models');
// NOTE view engine setting
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
global.token = '';
const cookieParser = require('cookie-parser');
app.use(cookieParser());
app.use(session({
secret: process.env.SECRET,
resave: false,
saveUninitialized: true,
}));
app.use(helmet());
app.use(logger('dev'));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.json());
/*
app.use(express.urlencoded({ extended: false }));
*/
app.use('/', require('./routes'));
app.use('/slack/events', require('./routes/slack_events'));
app.use('/slack/slashs', require('./routes/slack_slashs'));
app.use((err, req, res, next) => {
console.error(err);
res.status(404).send('Not Found');
})
db.sequelize.sync().then((req) => {
app.listen(PORT, () => {
console.log(`Listening on ${ PORT }`)
});
});