mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:57:08 +00:00
Add API endpoint for creating a project
This commit is contained in:
@@ -87,6 +87,7 @@ app.use(mw.auth.authentify);
|
||||
app.map({
|
||||
'/project': {
|
||||
get: [ mw.project.get ], // Get list of projects
|
||||
post: [ mw.auth.access.admin, mw.project.post ], // Create a new project
|
||||
},
|
||||
'/project/:project': {
|
||||
get: [ mw.project.summary.get ], // Get project data
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
module.exports = {
|
||||
get: require('./get'),
|
||||
post: require('./post'),
|
||||
summary: require('./summary'),
|
||||
};
|
||||
|
||||
16
lib/www/server/api/middleware/project/post.js
Normal file
16
lib/www/server/api/middleware/project/post.js
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
const { project } = require('../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
try {
|
||||
const payload = req.body;
|
||||
|
||||
const projectDefinition = await project.post(payload);
|
||||
res.status(201).send(projectDefinition);
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user