mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:37:07 +00:00
Catch all middleware errors
This commit is contained in:
@@ -27,7 +27,6 @@ module.exports = async function (req, res, next) {
|
||||
res.status(204).send();
|
||||
next();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
next(err);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@ const { event } = require('../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
res.status(200).send(await event.list(req.params.project, req.query));
|
||||
next();
|
||||
try {
|
||||
res.status(200).send(await event.list(req.params.project, req.query));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ const { event } = require('../../../lib/db');
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
try {
|
||||
const payload = Object.assign({}, req.body);
|
||||
const payload = req.body;
|
||||
|
||||
if (req.params.type) {
|
||||
payload.type = req.params.type;
|
||||
@@ -31,7 +31,6 @@ module.exports = async function (req, res, next) {
|
||||
res.status(201).send();
|
||||
next();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
next(err);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const { event } = require('../../../lib/db');
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
try {
|
||||
const payload = Object.assign({}, req.body);
|
||||
const payload = req.body;
|
||||
|
||||
if (req.params.type) {
|
||||
payload.type = req.params.type;
|
||||
@@ -31,7 +31,6 @@ module.exports = async function (req, res, next) {
|
||||
res.status(201).send();
|
||||
next();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
next(err);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@ const { gis } = require('../../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
res.status(200).send(await gis.project.bbox(req.params.project));
|
||||
next();
|
||||
try {
|
||||
res.status(200).send(await gis.project.bbox(req.params.project));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -30,8 +30,12 @@ module.exports = async function (req, res, next) {
|
||||
|
||||
const options = makeOptions(req.query);
|
||||
|
||||
res.set("Cache-Control", "public, max-age=30");
|
||||
res.status(200).send(await handler(req.params.project, options));
|
||||
next();
|
||||
try {
|
||||
res.set("Cache-Control", "public, max-age=30");
|
||||
res.status(200).send(await handler(req.params.project, options));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -34,8 +34,12 @@ module.exports = async function (req, res, next) {
|
||||
|
||||
const options = makeOptions(req.query);
|
||||
|
||||
res.set("Cache-Control", "public, max-age=30");
|
||||
res.status(200).send(await handler(req.params.project, options));
|
||||
next();
|
||||
try {
|
||||
res.set("Cache-Control", "public, max-age=30");
|
||||
res.status(200).send(await handler(req.params.project, options));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -30,7 +30,11 @@ module.exports = async function (req, res, next) {
|
||||
|
||||
const options = makeOptions(req.query);
|
||||
|
||||
res.status(200).send(await handler(req.params.project, options));
|
||||
next();
|
||||
try {
|
||||
res.status(200).send(await handler(req.params.project, options));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -3,7 +3,11 @@ const { label } = require('../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
res.status(200).send(await label.list(req.params.project, req.query));
|
||||
next();
|
||||
try {
|
||||
res.status(200).send(await label.list(req.params.project, req.query));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -3,7 +3,11 @@ const { line } = require('../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
res.status(200).send(await line.list(req.params.project, req.query));
|
||||
next();
|
||||
try {
|
||||
res.status(200).send(await line.list(req.params.project, req.query));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -3,7 +3,11 @@ const { project} = require('../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
res.status(200).send(await project.summary(req.params.project));
|
||||
next();
|
||||
try {
|
||||
res.status(200).send(await project.summary(req.params.project));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -3,7 +3,12 @@ const { project} = require('../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
res.status(200).send(await project.list());
|
||||
next();
|
||||
try {
|
||||
res.status(200).send(await project.list());
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -3,8 +3,12 @@ const { sequence } = require('../../../lib/db');
|
||||
|
||||
module.exports = async function (req, res, next) {
|
||||
|
||||
console.log(req.query);
|
||||
res.status(200).send(await sequence.list(req.params.project, req.query));
|
||||
next();
|
||||
try {
|
||||
res.status(200).send(await sequence.list(req.params.project, req.query));
|
||||
next();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user