-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.js
41 lines (33 loc) · 1.07 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
import express from 'express';
import logger from 'morgan';
import mustache from 'mustache-express';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import rts_index from './routes/index.js';
const app = express();
// Logging, can go to file, if requested
if (!!process.env.NODE_RVERSIONS_APP_LOGFILE) {
app.use(logger('combined', {
stream: fs.createWriteStream(process.env.NODE_RVERSIONS_APP_LOGFILE)
}));
} else {
app.use(logger('combined'));
}
app.use(express.urlencoded({ extended: false }));
app.use('/rversions/', express.static('public'))
app.engine('mustache', mustache());
app.set('view engine', 'mustache');
app.set('views', __dirname + '/views');
app.use('/rversions/', rts_index)
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.status(404)
.send({
error: 'End point not found, see documentation',
message: err.messge || ""
});
});
export default app;