-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
app.js
33 lines (24 loc) · 946 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
const express = require('express');
const helmet = require('helmet');
const rawBody = require('./middleware/rawBody');
const mongoose = require('./middleware/mongoose');
const render = require('./middleware/render');
const app = express();
const home = require('./routes/home');
const getSnippet = require('./routes/getSnippet');
const createSnippet = require('./routes/createSnippet');
const fork = require('./routes/fork');
app.use(helmet());
app.use(express.static(__dirname + '/public'));
app.use('/custom', express.static(__dirname + '/custom'));
app.use(express.urlencoded({extended: true})); // parse formdata
app.use(express.json()); // parse JSON requests
app.use(rawBody());
app.use(mongoose());
app.use(render());
app.post('/fork', fork);
app.post('/', createSnippet);
app.get('/~:id', getSnippet);
app.get('/', home);
const PORT = process.env.BIN_PORT || 1998;
app.listen(PORT, () => console.log('Listening on port', PORT));