mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:17:08 +00:00
Add API endpoint to retrieve line name properties.
This will be needed by the configuration GUI.
This commit is contained in:
@@ -185,6 +185,17 @@ app.map({
|
||||
delete: [ mw.auth.access.write, mw.plan.delete ]
|
||||
},
|
||||
|
||||
/*
|
||||
* Line name endpoints
|
||||
*/
|
||||
|
||||
'/project/:project/linename': {
|
||||
post: [ mw.linename.post ], // Get a linename
|
||||
},
|
||||
'/project/:project/linename/properties': {
|
||||
get: [ mw.linename.properties.get ], // Get linename properties
|
||||
},
|
||||
|
||||
/*
|
||||
* Event log endpoints
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ module.exports = {
|
||||
files: require('./files'),
|
||||
plan: require('./plan'),
|
||||
line: require('./line'),
|
||||
linename: require('./linename'),
|
||||
project: require('./project'),
|
||||
sequence: require('./sequence'),
|
||||
user: require('./user'),
|
||||
|
||||
4
lib/www/server/api/middleware/linename/index.js
Normal file
4
lib/www/server/api/middleware/linename/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
properties: require('./properties'),
|
||||
post: require('./post'),
|
||||
};
|
||||
21
lib/www/server/api/middleware/linename/post.js
Normal file
21
lib/www/server/api/middleware/linename/post.js
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
const { linename } = require('../../../lib/db/linename');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
try {
|
||||
const payload = req.body;
|
||||
|
||||
const line = await linename.post(req.params.project, payload);
|
||||
if (line) {
|
||||
res.status(200).type("text/plain").send(line);
|
||||
} else {
|
||||
res.status(404).send();
|
||||
}
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
21
lib/www/server/api/middleware/linename/properties/get.js
Normal file
21
lib/www/server/api/middleware/linename/properties/get.js
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
const { linename } = require('../../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
try {
|
||||
const payload = req.body;
|
||||
|
||||
const properties = await linename.properties.get(req.params.project, payload);
|
||||
if (properties) {
|
||||
res.status(200).send(properties);
|
||||
} else {
|
||||
res.status(404).send();
|
||||
}
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
get: require('./get'),
|
||||
};
|
||||
Reference in New Issue
Block a user