Skip to content

Commit

Permalink
Merge pull request #29 from Chia-Network/dev/michael.taylor/stage-res…
Browse files Browse the repository at this point in the history
…ource

feat: implement staging crud
  • Loading branch information
MichaelTaylor3D authored Dec 8, 2021
2 parents 6ba5853 + 912b316 commit 1e15a02
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 1e15a02

Please sign in to comment.