Follow linter

This commit is contained in:
syuilo 2017-03-04 04:28:38 +09:00
parent 4e3d617797
commit 3c1b92baa1
70 changed files with 514 additions and 780 deletions

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -13,9 +11,7 @@ import Like from '../../../models/like';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id).expect.id().required().qed();
if (postIdErr) return rej('invalid post_id param');
@ -63,7 +59,7 @@ module.exports = (params) =>
)[0];
if (data) {
graph.push(data)
graph.push(data);
} else {
graph.push({
date: {
@ -72,8 +68,8 @@ module.exports = (params) =>
day: day.getDate()
},
count: 0
})
};
});
}
}
res(graph);

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -13,9 +11,7 @@ import Like from '../../../models/like';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id).expect.id().required().qed();
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -12,9 +10,7 @@ import Post from '../../../models/post';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id).expect.id().required().qed();
if (postIdErr) return rej('invalid post_id param');
@ -62,7 +58,7 @@ module.exports = (params) =>
)[0];
if (data) {
graph.push(data)
graph.push(data);
} else {
graph.push({
date: {
@ -71,8 +67,8 @@ module.exports = (params) =>
day: day.getDate()
},
count: 0
})
};
});
}
}
res(graph);

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -12,9 +10,7 @@ import Post from '../../../models/post';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id).expect.id().required().qed();
if (postIdErr) return rej('invalid post_id param');
@ -62,7 +58,7 @@ module.exports = (params) =>
)[0];
if (data) {
graph.push(data)
graph.push(data);
} else {
graph.push({
date: {
@ -71,8 +67,8 @@ module.exports = (params) =>
day: day.getDate()
},
count: 0
})
};
});
}
}
res(graph);

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -13,9 +11,7 @@ import Following from '../../../models/following';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [userId, userIdErr] = it(params.user_id).expect.id().required().qed();
if (userIdErr) return rej('invalid user_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -13,9 +11,7 @@ import Following from '../../../models/following';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [userId, userIdErr] = it(params.user_id).expect.id().required().qed();
if (userIdErr) return rej('invalid user_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -13,9 +11,7 @@ import Like from '../../../models/like';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [userId, userIdErr] = it(params.user_id).expect.id().required().qed();
if (userIdErr) return rej('invalid user_id param');
@ -67,7 +63,7 @@ module.exports = (params) =>
)[0];
if (data) {
graph.push(data)
graph.push(data);
} else {
graph.push({
date: {
@ -76,8 +72,8 @@ module.exports = (params) =>
day: day.getDate()
},
count: 0
})
};
});
}
}
res(graph);

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -13,9 +11,7 @@ import Post from '../../../models/post';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [userId, userIdErr] = it(params.user_id).expect.id().required().qed();
if (userIdErr) return rej('invalid user_id param');
@ -95,7 +91,7 @@ module.exports = (params) =>
)[0];
if (data) {
graph.push(data)
graph.push(data);
} else {
graph.push({
date: {
@ -106,8 +102,8 @@ module.exports = (params) =>
posts: 0,
reposts: 0,
replies: 0
})
};
});
}
}
res(graph);

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -69,9 +67,7 @@ import serialize from '../../serializers/app';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = async (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = async (params, user) => new Promise(async (res, rej) => {
// Get 'name_id' parameter
const [nameId, nameIdErr] = it(params.name_id).expect.string().required().validate(isValidNameId).qed();
if (nameIdErr) return rej('invalid name_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -42,9 +40,7 @@ import { isValidNameId } from '../../../models/app';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = async (params) =>
new Promise(async (res, rej) =>
{
module.exports = async (params) => new Promise(async (res, rej) => {
// Get 'name_id' parameter
const [nameId, nameIdErr] = it(params.name_id).expect.string().required().validate(isValidNameId).qed();
if (nameIdErr) return rej('invalid name_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -46,9 +44,7 @@ import serialize from '../../serializers/app';
* @param {any} isSecure
* @return {Promise<any>}
*/
module.exports = (params, user, _, isSecure) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => {
// Get 'app_id' parameter
const [appId, appIdErr] = it(params.app_id, 'id');
if (appIdErr) return rej('invalid app_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -40,9 +38,7 @@ import AccessToken from '../../models/access-token';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'token' parameter
const [token, tokenErr] = it(params.token).expect.string().required().qed();
if (tokenErr) return rej('invalid token param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -46,9 +44,7 @@ import config from '../../../../conf';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'app_secret' parameter
const [appSecret, appSecretErr] = it(params.app_secret).expect.string().required().qed();
if (appSecretErr) return rej('invalid app_secret param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -54,9 +52,7 @@ import serialize from '../../../serializers/auth-session';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'token' parameter
const [token, tokenErr] = it(params.token).expect.string().required().qed();
if (tokenErr) return rej('invalid token param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -51,8 +49,7 @@ import serialize from '../../../serializers/user';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) => {
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'app_secret' parameter
const [appSecret, appSecretErr] = it(params.app_secret).expect.string().required().qed();
if (appSecretErr) return rej('invalid app_secret param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -12,8 +10,7 @@ import DriveFile from '../models/drive-file';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {
module.exports = (params, user) => new Promise(async (res, rej) => {
// Calculate drive usage
const usage = ((await DriveFile
.aggregate([

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,9 +13,7 @@ import serialize from '../../serializers/drive-file';
* @param {any} app
* @return {Promise<any>}
*/
module.exports = (params, user, app) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user, app) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -17,15 +15,13 @@ import create from '../../../common/add-file-to-drive';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (file, params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (file, params, user) => new Promise(async (res, rej) => {
if (file == null) {
return rej('file is required');
}
const buffer = fs.readFileSync(file.path);
fs.unlink(file.path, (err) => { if (err) console.log(err) });
fs.unlink(file.path, (err) => { if (err) console.log(err); });
// Get 'name' parameter
let name = file.originalname;

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../../serializers/drive-file';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = it(params.name).expect.string().required().qed();
if (nameErr) return rej('invalid name param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../../serializers/drive-file';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'file_id' parameter
const [fileId, fileIdErr] = it(params.file_id).expect.id().required().qed();
if (fileIdErr) return rej('invalid file_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -17,9 +15,7 @@ import event from '../../../event';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'file_id' parameter
const [fileId, fileIdErr] = it(params.file_id).expect.id().required().qed();
if (fileIdErr) return rej('invalid file_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -17,9 +15,7 @@ import create from '../../../common/add-file-to-drive';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'url' parameter
// TODO: Validate this url
const [url, urlErr] = it(params.url).expect.string().required().qed();

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,9 +13,7 @@ import serialize from '../../serializers/drive-folder';
* @param {any} app
* @return {Promise<any>}
*/
module.exports = (params, user, app) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user, app) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -16,9 +14,7 @@ import event from '../../../event';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = it(params.name).expect.string().validate(isValidFolderName).default('無題のフォルダー').qed();
if (nameErr) return rej('invalid name param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../../serializers/drive-folder';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = it(params.name).expect.string().required().qed();
if (nameErr) return rej('invalid name param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../../serializers/drive-folder';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'folder_id' parameter
const [folderId, folderIdErr] = it(params.folder_id).expect.id().required().qed();
if (folderIdErr) return rej('invalid folder_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -16,9 +14,7 @@ import event from '../../../event';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'folder_id' parameter
const [folderId, folderIdErr] = it(params.folder_id).expect.id().required().qed();
if (folderIdErr) return rej('invalid folder_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/drive-file';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -17,9 +15,7 @@ import serializeUser from '../../serializers/user';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
const follower = user;
// Get 'user_id' parameter

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -16,9 +14,7 @@ import serializeUser from '../../serializers/user';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
const follower = user;
// Get 'user_id' parameter

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../serializers/user';
* @param {Boolean} isSecure
* @return {Promise<any>}
*/
module.exports = (params, user, _, isSecure) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => {
// Serialize
res(await serialize(user, user, {
detail: true,

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import Appdata from '../../../models/appdata';
* @param {Boolean} isSecure
* @return {Promise<any>}
*/
module.exports = (params, user, app, isSecure) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) => {
// Get 'key' parameter
let key = params.key;
if (key === undefined) {

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -17,9 +15,7 @@ import event from '../../../event';
* @param {Boolean} isSecure
* @return {Promise<any>}
*/
module.exports = (params, user, app, isSecure) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) => {
const data = params.data;
if (data == null) {
return rej('data is required');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/app';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/post';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,9 +13,7 @@ import getFriends from '../../common/get-friends';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'following' parameter
const [following, followingError] =
it(params.following).expect.boolean().default(false).qed();

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/signin';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -19,9 +17,7 @@ import config from '../../../conf';
* @param {boolean} isSecure
* @return {Promise<any>}
*/
module.exports = async (params, user, _, isSecure) =>
new Promise(async (res, rej) =>
{
module.exports = async (params, user, _, isSecure) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = it(params.name).expect.string().validate(isValidName).qed();
if (nameErr) return rej('invalid name param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/messaging-message';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -17,9 +15,7 @@ import { publishMessagingStream } from '../../event';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [recipientId, recipientIdErr] = it(params.user_id).expect.id().required().qed();
if (recipientIdErr) return rej('invalid user_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -21,9 +19,7 @@ import config from '../../../../conf';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [recipientId, recipientIdErr] = it(params.user_id).expect.id().required().qed();
if (recipientIdErr) return rej('invalid user_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -12,9 +10,7 @@ import Message from '../../models/messaging-message';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
const count = await Message
.count({
recipient_id: user._id,

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -40,8 +38,7 @@ import config from '../../conf';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) => {
module.exports = (params) => new Promise(async (res, rej) => {
const commit = await prominence(git).getLastCommit();
res({

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/app';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,8 +13,7 @@ import event from '../../event';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {
module.exports = (params, user) => new Promise(async (res, rej) => {
const [notificationId, notificationIdErr] = it(params.notification_id).expect.id().required().qed();
if (notificationIdErr) return rej('invalid notification_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -13,8 +11,7 @@ import serialize from '../serializers/post';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) => {
module.exports = (params) => new Promise(async (res, rej) => {
// Get 'include_replies' parameter
const [includeReplies, includeRepliesErr] = it(params.include_replies).expect.boolean().default(true).qed();
if (includeRepliesErr) return rej('invalid include_replies param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/post';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -23,9 +21,7 @@ import config from '../../../conf';
* @param {any} app
* @return {Promise<any>}
*/
module.exports = (params, user, app) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user, app) => new Promise(async (res, rej) => {
// Get 'text' parameter
const [text, textErr] = it(params.text).must.be.a.string().validate(isValidText).qed();
if (textErr) return rej('invalid text');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,8 +12,7 @@ import Post from '../../../models/post';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,8 +12,7 @@ import Post from '../../../models/post';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,9 +13,7 @@ import serialize from '../../serializers/user';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -16,8 +14,7 @@ import notify from '../../../common/notify';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -16,8 +14,7 @@ import User from '../../../models/user';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,9 +13,7 @@ import serialize from '../../serializers/post';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'following' parameter
const [following, followingError] =
it(params.following).expect.boolean().default(false).qed();

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,8 +13,7 @@ import notify from '../../../common/notify';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/post';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/post';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -17,9 +15,7 @@ import config from '../../../conf';
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'query' parameter
const [query, queryError] = it(params.query).expect.string().required().trim().validate(x => x != '').qed();
if (queryError) return rej('invalid query param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/post';
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -16,9 +14,7 @@ import serialize from '../../serializers/post';
* @param {any} app
* @return {Promise<any>}
*/
module.exports = (params, user, app) =>
new Promise(async (res, rej) =>
{
module.exports = (params, user, app) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -13,9 +11,7 @@ import { validateUsername } from '../../models/user';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = async (params) =>
new Promise(async (res, rej) =>
{
module.exports = async (params) => new Promise(async (res, rej) => {
// Get 'username' parameter
const [username, usernameError] = it(params.username).expect.string().required().trim().validate(validateUsername).qed();
if (usernameError) return rej('invalid username param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,8 +12,7 @@ import serialize from '../serializers/user';
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) => {
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -16,9 +14,7 @@ import getFriends from '../../common/get-friends';
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [userId, userIdErr] = it(params.user_id, 'id', true);
if (userIdErr) return rej('invalid user_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -16,9 +14,7 @@ import getFriends from '../../common/get-friends';
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [userId, userIdErr] = it(params.user_id, 'id', true);
if (userIdErr) return rej('invalid user_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,9 +13,7 @@ import serialize from '../../serializers/post';
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [userId, userIdErr] = it(params.user_id, 'id');
if (userIdErr) return rej('invalid user_id param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,9 +13,7 @@ import getFriends from '../../common/get-friends';
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
if (limitErr) return rej('invalid limit param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -17,9 +15,7 @@ const escapeRegexp = require('escape-regexp');
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'query' parameter
const [query, queryError] = it(params.query).expect.string().required().trim().validate(x => x != '').qed();
if (queryError) return rej('invalid query param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -15,9 +13,7 @@ import serialize from '../../serializers/user';
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'query' parameter
const [query, queryError] = it(params.query).expect.string().required().trim().validate(validateUsername).qed();
if (queryError) return rej('invalid query param');

View File

@ -1,5 +1,3 @@
'use strict';
/**
* Module dependencies
*/
@ -14,9 +12,7 @@ import serialize from '../../serializers/user';
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
const [userId, userIdErr] = it(params.user_id, 'id');
if (userIdErr) return rej('invalid user_id param');

View File

@ -5,4 +5,3 @@ export default db.get('messaging_messages') as any; // fuck type definition
export function isValidText(text: string): boolean {
return text.length <= 1000 && text.trim() != '';
}