Add API endpoint to delete a project

This commit is contained in:
D. Berge
2023-08-23 19:22:57 +02:00
parent 38a07dffc6
commit fe9d3563a0
3 changed files with 17 additions and 0 deletions

View File

@@ -91,6 +91,7 @@ app.map({
},
'/project/:project': {
get: [ mw.project.summary.get ], // Get project data
delete: [ mw.auth.access.admin, mw.project.delete ], // Delete a project (only if empty)
},
'/project/:project/summary': {
get: [ mw.project.summary.get ],

View File

@@ -0,0 +1,15 @@
const { project} = require('../../../lib/db');
module.exports = async function (req, res, next) {
try {
await project.delete(req.params.project)
res.status(204).send();
next();
} catch (err) {
next(err);
}
};

View File

@@ -1,6 +1,7 @@
module.exports = {
get: require('./get'),
post: require('./post'),
delete: require('./delete'),
summary: require('./summary'),
configuration: require('./configuration'),
};