-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
31 lines (27 loc) · 944 Bytes
/
server.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
'use strict';
const express = require('express');
const app = express();
const compression = require('compression');
const helmet = require('helmet');
const port = process.env.PORT || 3000;
const bodyParser = require('body-parser');
const rmt = require('./rmt.js').rmt;
const parser = require('./bbparser.js').parser;
const finishParse = require('./bbparser.js').finishParse;
app.use(compression());
app.use(helmet());
app.set('view engine', 'pug');
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.get('/', function (req, res) {
res.render('index');
});
app.post('/rmt', function (req, res) {
let output = rmt(req.body['team'], req.body['options']);
if (req.body['format'] === 'html') res.send(finishParse(parser.parseString(output)));
else res.send(output);
});
app.listen(port, function () {
console.log(`Example app listening on port: ${port}`);
});