Add /version API endpoint

This commit is contained in:
D. Berge
2023-11-02 19:48:30 +01:00
parent f0fa2b75d5
commit 620d5ccf47
4 changed files with 28 additions and 1 deletions

View File

@@ -88,6 +88,9 @@ app.use(mw.etag.ifNoneMatch);
// We must be authenticated before we can access these // We must be authenticated before we can access these
app.map({ app.map({
'/version': {
get: [ mw.version.get ]
},
'/project': { '/project': {
get: [ mw.project.get ], // Get list of projects get: [ mw.project.get ], // Get list of projects
post: [ mw.auth.access.admin, mw.project.post ], // Create a new project post: [ mw.auth.access.admin, mw.project.post ], // Create a new project

View File

@@ -17,5 +17,6 @@ module.exports = {
meta: require('./meta'), meta: require('./meta'),
openapi: require('./openapi'), openapi: require('./openapi'),
rss: require('./rss'), rss: require('./rss'),
etag: require('./etag') etag: require('./etag'),
version: require('./version')
}; };

View File

@@ -0,0 +1,19 @@
const version = require('../../../lib/version');
module.exports = async function (req, res, next) {
try {
const v = await version();
if (req.user.role != "admin" && req.user.role != "user") {
delete v.os;
delete v.db;
}
res.status(200).json(v);
} catch (err) {
next(err);
return;
}
next();
};

View File

@@ -0,0 +1,4 @@
module.exports = {
get: require('./get')
}