1 | const HttpStatus = require('http-status');
|
2 | const ObjectId = require('../../models/objectId');
|
3 | const services = require('../../services');
|
4 | const utils = require('../../../config/utils');
|
5 |
|
6 | module.exports = {
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 | add: (req, res) =>
|
13 | new ObjectId({namespace: req.params.namespace, id: req.params.id}).validate()
|
14 | .then((objectId) => services.mutators.add(objectId, req.body))
|
15 | .then(() => res.status(HttpStatus.OK).json())
|
16 | .catch((e) => utils.processError(e, res)),
|
17 |
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 | delete: (req, res) =>
|
24 | new ObjectId({namespace: req.params.namespace, id: req.params.id}).validate()
|
25 | .then((objectId) => services.mutators.remove(objectId))
|
26 | .then(() => res.status(HttpStatus.NO_CONTENT).json())
|
27 | .catch((e) => utils.processError(e, res)),
|
28 |
|
29 | |
30 |
|
31 |
|
32 | getAllIdsByNamespace: (req, res) =>
|
33 | new ObjectId({namespace: req.params.namespace, id: 'dummy'}).validate()
|
34 | .then((objectId) => services.mutators.getIds(objectId.namespace))
|
35 | .then((ids) => res.status(HttpStatus.OK).json({ids}))
|
36 | .catch((e) => utils.processError(e, res))
|
37 | }; |
\ | No newline at end of file |