Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
implement #19 GET /posts/:id
Browse files Browse the repository at this point in the history
  • Loading branch information
marihachi committed Jul 29, 2017
1 parent 59f530f commit 826a96f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/routes/posts/id.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const ApiResult = require('../../helpers/apiResult');
const Post = require('../../documentModels/post');

exports.get = async (request) => {
const result = await request.checkRequestAsync({
Expand All @@ -12,5 +13,10 @@ exports.get = async (request) => {
return result;
}

return new ApiResult(501, 'not implemented');
const post = await Post.findByIdAsync(request.params.id, request.db, request.config);

if (post == null) {
return new ApiResult(204);
}
return new ApiResult(200, {post: post.serialize()});
};

0 comments on commit 826a96f

Please sign in to comment.