This commit is contained in:
syuilo 2017-03-03 19:52:36 +09:00
parent d7875cc0fe
commit 7a472760cd
8 changed files with 32 additions and 48 deletions

View File

@ -3,7 +3,7 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import it from '../../../it';
import Post from '../../../models/post';
import Like from '../../../models/like';
@ -17,14 +17,12 @@ module.exports = (params) =>
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');
}
const [postId, postIdErr] = it(params.post_id).expect.id().required().qed();
if (postIdErr) return rej('invalid post_id param');
// Lookup post
const post = await Post.findOne({
_id: new mongo.ObjectID(postId)
_id: postId
});
if (post === null) {

View File

@ -3,7 +3,7 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import it from '../../../it';
import Post from '../../../models/post';
import Like from '../../../models/like';
@ -17,14 +17,12 @@ module.exports = (params) =>
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');
}
const [postId, postIdErr] = it(params.post_id).expect.id().required().qed();
if (postIdErr) return rej('invalid post_id param');
// Lookup post
const post = await Post.findOne({
_id: new mongo.ObjectID(postId)
_id: postId
});
if (post === null) {

View File

@ -3,7 +3,7 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import it from '../../../it';
import Post from '../../../models/post';
/**
@ -16,14 +16,12 @@ module.exports = (params) =>
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');
}
const [postId, postIdErr] = it(params.post_id).expect.id().required().qed();
if (postIdErr) return rej('invalid post_id param');
// Lookup post
const post = await Post.findOne({
_id: new mongo.ObjectID(postId)
_id: postId
});
if (post === null) {

View File

@ -3,7 +3,7 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import it from '../../../it';
import Post from '../../../models/post';
/**
@ -16,14 +16,12 @@ module.exports = (params) =>
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');
}
const [postId, postIdErr] = it(params.post_id).expect.id().required().qed();
if (postIdErr) return rej('invalid post_id param');
// Lookup post
const post = await Post.findOne({
_id: new mongo.ObjectID(postId)
_id: postId
});
if (post === null) {

View File

@ -3,7 +3,7 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import it from '../../../it';
import User from '../../../models/user';
import Following from '../../../models/following';
@ -17,14 +17,12 @@ module.exports = (params) =>
new Promise(async (res, rej) =>
{
// Get 'user_id' parameter
const userId = params.user_id;
if (userId === undefined || userId === null) {
return rej('user_id is required');
}
const [userId, userIdErr] = it(params.user_id).expect.id().required().qed();
if (userIdErr) return rej('invalid user_id param');
// Lookup user
const user = await User.findOne({
_id: new mongo.ObjectID(userId)
_id: userId
}, {
fields: {
_id: true

View File

@ -3,7 +3,7 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import it from '../../../it';
import User from '../../../models/user';
import Following from '../../../models/following';
@ -17,14 +17,12 @@ module.exports = (params) =>
new Promise(async (res, rej) =>
{
// Get 'user_id' parameter
const userId = params.user_id;
if (userId === undefined || userId === null) {
return rej('user_id is required');
}
const [userId, userIdErr] = it(params.user_id).expect.id().required().qed();
if (userIdErr) return rej('invalid user_id param');
// Lookup user
const user = await User.findOne({
_id: new mongo.ObjectID(userId)
_id: userId
}, {
fields: {
_id: true

View File

@ -3,7 +3,7 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import it from '../../../it';
import User from '../../../models/user';
import Like from '../../../models/like';
@ -17,14 +17,12 @@ module.exports = (params) =>
new Promise(async (res, rej) =>
{
// Get 'user_id' parameter
const userId = params.user_id;
if (userId === undefined || userId === null) {
return rej('user_id is required');
}
const [userId, userIdErr] = it(params.user_id).expect.id().required().qed();
if (userIdErr) return rej('invalid user_id param');
// Lookup user
const user = await User.findOne({
_id: new mongo.ObjectID(userId)
_id: userId
}, {
fields: {
_id: true

View File

@ -3,7 +3,7 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import it from '../../../it';
import User from '../../../models/user';
import Post from '../../../models/post';
@ -17,14 +17,12 @@ module.exports = (params) =>
new Promise(async (res, rej) =>
{
// Get 'user_id' parameter
const userId = params.user_id;
if (userId === undefined || userId === null) {
return rej('user_id is required');
}
const [userId, userIdErr] = it(params.user_id).expect.id().required().qed();
if (userIdErr) return rej('invalid user_id param');
// Lookup user
const user = await User.findOne({
_id: new mongo.ObjectID(userId)
_id: userId
}, {
fields: {
_id: true