Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

admin submission endpoints #259

Open
wants to merge 12 commits into
base: env/dev
Choose a base branch
from
35 changes: 35 additions & 0 deletions server/api/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,41 @@ router.get('/:submissionID', async (req, res) => {
* tags:
* - submissions
*/

router.post('/', (req, res) => {
Submission.create({}, () => {
if (
!req.body.title ||
!req.body.description ||
!req.body.technologies ||
!req.body.category ||
!req.body.urls ||
!req.body.flags
) {
res.status(500).send({ message: 'Content can not be empty!' });
return;
}
const submission = new Submission({
title: req.body.title,
description: req.body.description,
technologies: req.body.technologies,
urls: req.body.urls,
categories: req.body.categories,
published: req.body.published ? req.body.published : false,
});
submission
.save(submission)
.then((data) => {
res.send(data);
})
.catch((err) => {
res.status(200).send({
message: err.message,
});
});
});
});

router.post('/', (req, res) => {
Submission.create({}, (err, submission) => {
if (err) res.status(500).send(err);
Expand Down
1 change: 0 additions & 1 deletion server/api/submissions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ describe('testing submission endpoints', () => {
const res = await request.get('/api/submissions');
expect(res.statusCode).toEqual(200);
expect(res.body).not.toBeNull();
console.log(res.body);
done();
});
});
Expand Down
Loading