Commit 5c2b447a authored by Nelson GONCALVES's avatar Nelson GONCALVES
Browse files

doImport can throw, catch it and send JSON instead

parent 32b0d1ce
......@@ -81,14 +81,18 @@ exports.expressCreateServer = function (hook_name, args, cb) {
return next();
}
const apiKeyParam = req.params.apikey || req.params.api_key;
const apiKeyParam = req.query.apikey || req.query.api_key;
if (apiKeyParam !== apikey.trim()) {
res.statusCode = 401;
return res.send({ code: 4, message: 'no or wrong API Key', data: null });
}
importHandler.doImport(req, res, req.params.pad);
try {
importHandler.doImport(req, res, req.params.pad);
} catch(err) {
laclasseLogger.error(err);
return res.send({ code: 2, message: err, data: null });
}
});
return cb();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment