feat(writeapi): post delete/restore/purge

This commit is contained in:
Julian Lam
2020-10-06 14:12:02 -04:00
parent f66c2fb60f
commit 414169fdfa
5 changed files with 129 additions and 47 deletions

View File

@@ -8,6 +8,7 @@
const user = require('../user');
const groups = require('../groups');
const topics = require('../topics');
const posts = require('../posts');
const helpers = require('../controllers/helpers');
@@ -36,4 +37,12 @@ module.exports = function (middleware) {
next();
};
middleware.assertPost = async (req, res, next) => {
if (!await posts.exists(req.params.pid)) {
return helpers.formatApiResponse(404, res, new Error('[[error:no-topic]]'));
}
next();
};
};