-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (21 loc) · 788 Bytes
/
index.js
File metadata and controls
30 lines (21 loc) · 788 Bytes
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
if (process.env.NODE_ENV !== 'production') {
require('dotenv').load();
}
let express = require('express');
let app = express();
let path = require('path');
let http = require('http');
let api = require('./server/routes/api');
let mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URI, {useNewUrlParser: true});
app.use(express.static(path.join(__dirname, '/public')));
app.use('/api', api);
app.get('/help', (req, res) => {
res.sendFile(path.join(__dirname, '/public/help.html'));
});
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '/public/index.html'));
});
app.set('port', process.env.PORT);
let server = http.createServer(app);
server.listen(process.env.PORT, () => console.log(`SlackBall api running on localhost:${process.env.PORT}`));