From 6e181ee0f1ca2ecd0fdf3a78654607ef112f2a6a Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 3 Mar 2017 06:48:26 +0900 Subject: wip --- src/api/endpoints/posts/show.js | 44 ----------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/api/endpoints/posts/show.js (limited to 'src/api/endpoints/posts/show.js') diff --git a/src/api/endpoints/posts/show.js b/src/api/endpoints/posts/show.js deleted file mode 100644 index 4938199cdb..0000000000 --- a/src/api/endpoints/posts/show.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import Post from '../../models/post'; -import serialize from '../../serializers/post'; - -/** - * Show a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => - new Promise(async (res, rej) => -{ - // Get 'post_id' parameter - const postId = params.post_id; - if (postId === undefined || postId === null) { - return rej('post_id is required'); - } - - // Validate id - if (!mongo.ObjectID.isValid(postId)) { - return rej('incorrect post_id'); - } - - // Get post - const post = await Post.findOne({ - _id: new mongo.ObjectID(postId) - }); - - if (post === null) { - return rej('post not found'); - } - - // Serialize - res(await serialize(post, user, { - detail: true - })); -}); -- cgit v1.3.1-freya