Skip to content

Commit

Permalink
feat: implement staging crud
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael.Taylor committed Dec 7, 2021
1 parent 6ba5853 commit 912b316
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
41 changes: 15 additions & 26 deletions src/controllers/staging.controller.js
Original file line number Diff line number Diff line change
@@ -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());
Expand All @@ -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,
});
});
};
21 changes: 21 additions & 0 deletions src/routes/v1/resources/stagings.js
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit 912b316

Please sign in to comment.