diff --git a/src/controllers/staging.controller.js b/src/controllers/staging.controller.js index 51e3eae1..0fa0a33a 100644 --- a/src/controllers/staging.controller.js +++ b/src/controllers/staging.controller.js @@ -1,11 +1,5 @@ import { Staging, StagingMock } from '../models'; -export const create = (req, res) => { - res.json({ - message: 'Not Yet Implemented', - }); -}; - export const findAll = async (req, res) => { if (req.query.useMock) { res.json(StagingMock.findAll()); @@ -15,25 +9,20 @@ export const findAll = async (req, res) => { res.json(Staging.findAll()); }; -export const findOne = async (req, res) => { - if (req.query.useMock) { - res.json(StagingMock.findOne(req.query.id)); - return; - } - - res.json({ - message: 'Not Yet Implemented', - }); -}; - -export const update = (req, res) => { - res.json({ - message: 'Not Yet Implemented', - }); -}; - export const destroy = (req, res) => { - res.json({ - message: 'Not Yet Implemented', - }); + Staging.destroy({ + where: { + uuid: req.body.uuid, + }, + }) + .then(() => { + res.json({ + message: 'Deleted', + }); + }) + .catch((err) => { + res.json({ + message: err, + }); + }); }; diff --git a/src/routes/v1/resources/stagings.js b/src/routes/v1/resources/stagings.js new file mode 100644 index 00000000..6bc3ffe9 --- /dev/null +++ b/src/routes/v1/resources/stagings.js @@ -0,0 +1,21 @@ +'use strict'; + +import express from 'express'; +import { StagingController } from './staging./../../controllers'; +const StagingRouter = express.Router(); + +StagingRouter.get('/', (req, res) => { + return StagingController.findAll(req, res); +}); + +const querySchemaDelete = { + id: Joi.string().required(), +}; + +StagingRouter.delete( + '/', + validator.body(querySchemaDelete), + StagingController.destroy, +); + +export { StagingRouter };