add API for list creation

This commit is contained in:
antoninchadima 2019-03-20 13:38:06 +01:00 committed by GitHub
parent c3cf46a717
commit 51dd7938ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,6 +41,30 @@ router.all('/*', (req, res, next) => {
});
router.post('/listadd', (req, res) => {
let input = {};
Object.keys(req.body).forEach(key => {
input[(key || '').toString().trim().toUpperCase()] = (req.body[key] || '').toString().trim();
});
lists.create(req.body, (err, id) => {
if (err || !id) {
log.error('API', err);
res.status(500);
return res.json({
error: err.message || err,
data: []
});
}
res.status(200);
res.json({
data: {
id
}
});
});
});
router.post('/subscribe/:listId', (req, res) => {
let input = {};
Object.keys(req.body).forEach(key => {