-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
47 lines (39 loc) · 1.27 KB
/
server.js
File metadata and controls
47 lines (39 loc) · 1.27 KB
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
require('dotenv').config();
const debug = require('debug')('gopher-express');
const express = require('express');
const app = express();
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
// app.get('/', (req, res) => res.send('hi'));
app.use(bodyParser.json({
verify: function(req, res, buf, encoding) {
req.rawBody = buf.toString();
}
}));
app.use(bodyParser.json());
app.use(cookieParser());
const gopherUtils = require('./lib/gopherUtils');
const gopherAuth = require('./routes/gopherAuth');
app.use('/auth', gopherAuth);
const gopherCrud = require('./routes/gopherCrud');
app.use(gopherCrud);
/**
*
* Process and respond to webhooks in /routes/gopherWebhooks.js
*
*/
const webhooks = require('./routes/gopherWebhooks');
app.use('/webhooks', webhooks);
/**
*
* Edit public/index.html to update the settings page
*
*/
app.get('/', gopherUtils.requireLogin, (req, res) => {
res.sendFile(__dirname + '/public/index.html');
});
app.use('/gopher.js', gopherUtils.requireLogin, gopherUtils.jsTokenizer); // automatically populated with config values
app.use(express.static('public'));
const listener = app.listen(process.env.PORT || 3011, function () {
console.log('Your app is listening on port ' + listener.address().port);
});