Hide given file extensions

This commit is contained in:
Clément GOUIN
2019-06-20 13:05:18 +02:00
parent e88eb94d78
commit c755ea939d
3 changed files with 50 additions and 8 deletions
+9 -1
View File
@@ -17,7 +17,6 @@ module.exports = (config) => {
const articles = [];
const reload = (callback) => {
fw.fetchArticles((err, list) => {
if (err) {
@@ -32,6 +31,8 @@ module.exports = (config) => {
callback(true);
});
};
if (config['test'])
app.reload = reload;
const render = (res, path, data, code = 200) => {
res.render(path, data, (err, html) => {
@@ -63,6 +64,13 @@ module.exports = (config) => {
});
});
app.get('*', (req, res, next) => {
if (config['home']['hidden'].includes(path.extname(req.path)))
showError(req.path, 404, res);
else
next();
});
app.get('*', express.static(config['data_dir']));
app.get('*', (req, res) => {