-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
57 lines (45 loc) · 2.79 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
const conf = require('./config/config.js');
const express = require('express');
const app = express();
const http = require('http');
const bodyParser = require('body-parser');
const builder = require('./services/builder');
const HTTP_PORT = conf.get('port');
const redirectUrls = require('./services/redirectUrls');
app.set('view engine', 'ejs');
app.get('/.well-known/acme-challenge/:content', (req, res) => {
const content = req.param('content');
res.send(process.env['CERTBOT_RESPONSE:' + content]);
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// redirections
app.use('*', redirectUrls);
// build use
app.use('/build', builder.use);
// static stuff
app.use('/', express.static('public'));
app.use('/', express.static('content'));
// everything else
app.get('*', require('./services/router')(app));
app.post('*', require('./services/router')(app));
http.createServer(app).listen(HTTP_PORT, () => {
console.log(
`
██████╗ ███████╗██╗ ██╗ ██████╗ ██╗ ██╗ ██╗████████╗██╗ ██████╗ ███╗ ██╗
██╔══██╗██╔════╝██║ ██║██╔═══██╗██║ ██║ ██║╚══██╔══╝██║██╔═══██╗████╗ ██║
██████╔╝█████╗ ██║ ██║██║ ██║██║ ██║ ██║ ██║ ██║██║ ██║██╔██╗ ██║
██╔══██╗██╔══╝ ╚██╗ ██╔╝██║ ██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║
██║ ██║███████╗ ╚████╔╝ ╚██████╔╝███████╗╚██████╔╝ ██║ ██║╚██████╔╝██║ ╚████║
╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
██████╗ ██████╗ ███╗ ██╗███████╗
██╔════╝██╔═══██╗████╗ ██║██╔════╝
██║ ██║ ██║██╔██╗ ██║█████╗
██║ ██║ ██║██║╚██╗██║██╔══╝
╚██████╗╚██████╔╝██║ ╚████║██║
╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝
Unsecured server listening on port ` + HTTP_PORT
);
});
module.exports = app;