backend: Première route /functions/:functionName + Gestion des erreurs 404 et 500
This commit is contained in:
10
backend/controllers/functions.js
Normal file
10
backend/controllers/functions.js
Normal file
@ -0,0 +1,10 @@
|
||||
const functionToExecute = require('../assets/functions/functionObject');
|
||||
const sendResponse = require('../assets/utils/sendResponse');
|
||||
|
||||
exports.executeFunctionName = (req, res, _next) => {
|
||||
const functionObject = functionToExecute(req.params.functionName);
|
||||
if (functionObject !== undefined) {
|
||||
return functionObject.functionOutput(res, req.body);
|
||||
}
|
||||
return sendResponse(res, { result: "La fonction n'existe pas.", httpStatus: 404 });
|
||||
}
|
Reference in New Issue
Block a user