summaryrefslogtreecommitdiff
path: root/src/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-04 04:28:38 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-04 04:28:38 +0900
commit3c1b92baa1ac15c23fe63e2f50739105252ca516 (patch)
tree35a0ae58802891f05209c83e780440775075e088 /src/api/endpoints
parentMerge pull request #233 from syuilo/greenkeeper/inquirer-3.0.6 (diff)
downloadsharkey-3c1b92baa1ac15c23fe63e2f50739105252ca516.tar.gz
sharkey-3c1b92baa1ac15c23fe63e2f50739105252ca516.tar.bz2
sharkey-3c1b92baa1ac15c23fe63e2f50739105252ca516.zip
Follow linter
Diffstat (limited to 'src/api/endpoints')
-rw-r--r--src/api/endpoints/aggregation/posts/like.ts12
-rw-r--r--src/api/endpoints/aggregation/posts/likes.ts6
-rw-r--r--src/api/endpoints/aggregation/posts/reply.ts12
-rw-r--r--src/api/endpoints/aggregation/posts/repost.ts12
-rw-r--r--src/api/endpoints/aggregation/users/followers.ts6
-rw-r--r--src/api/endpoints/aggregation/users/following.ts6
-rw-r--r--src/api/endpoints/aggregation/users/like.ts12
-rw-r--r--src/api/endpoints/aggregation/users/post.ts12
-rw-r--r--src/api/endpoints/app/create.ts6
-rw-r--r--src/api/endpoints/app/name_id/available.ts6
-rw-r--r--src/api/endpoints/app/show.ts6
-rw-r--r--src/api/endpoints/auth/accept.ts6
-rw-r--r--src/api/endpoints/auth/session/generate.ts6
-rw-r--r--src/api/endpoints/auth/session/show.ts6
-rw-r--r--src/api/endpoints/auth/session/userkey.ts97
-rw-r--r--src/api/endpoints/drive.ts47
-rw-r--r--src/api/endpoints/drive/files.ts6
-rw-r--r--src/api/endpoints/drive/files/create.ts8
-rw-r--r--src/api/endpoints/drive/files/find.ts6
-rw-r--r--src/api/endpoints/drive/files/show.ts6
-rw-r--r--src/api/endpoints/drive/files/update.ts6
-rw-r--r--src/api/endpoints/drive/files/upload_from_url.ts6
-rw-r--r--src/api/endpoints/drive/folders.ts6
-rw-r--r--src/api/endpoints/drive/folders/create.ts6
-rw-r--r--src/api/endpoints/drive/folders/find.ts6
-rw-r--r--src/api/endpoints/drive/folders/show.ts6
-rw-r--r--src/api/endpoints/drive/folders/update.ts6
-rw-r--r--src/api/endpoints/drive/stream.ts6
-rw-r--r--src/api/endpoints/following/create.ts6
-rw-r--r--src/api/endpoints/following/delete.ts6
-rw-r--r--src/api/endpoints/i.ts6
-rw-r--r--src/api/endpoints/i/appdata/get.ts6
-rw-r--r--src/api/endpoints/i/appdata/set.ts6
-rw-r--r--src/api/endpoints/i/authorized_apps.ts6
-rw-r--r--src/api/endpoints/i/favorites.ts6
-rw-r--r--src/api/endpoints/i/notifications.ts6
-rw-r--r--src/api/endpoints/i/signin_history.ts6
-rw-r--r--src/api/endpoints/i/update.ts6
-rw-r--r--src/api/endpoints/messaging/history.ts6
-rw-r--r--src/api/endpoints/messaging/messages.ts6
-rw-r--r--src/api/endpoints/messaging/messages/create.ts6
-rw-r--r--src/api/endpoints/messaging/unread.ts6
-rw-r--r--src/api/endpoints/meta.ts17
-rw-r--r--src/api/endpoints/my/apps.ts6
-rw-r--r--src/api/endpoints/notifications/mark_as_read.ts55
-rw-r--r--src/api/endpoints/posts.ts101
-rw-r--r--src/api/endpoints/posts/context.ts6
-rw-r--r--src/api/endpoints/posts/create.ts6
-rw-r--r--src/api/endpoints/posts/favorites/create.ts59
-rw-r--r--src/api/endpoints/posts/favorites/delete.ts55
-rw-r--r--src/api/endpoints/posts/likes.ts6
-rw-r--r--src/api/endpoints/posts/likes/create.ts111
-rw-r--r--src/api/endpoints/posts/likes/delete.ts99
-rw-r--r--src/api/endpoints/posts/mentions.ts6
-rw-r--r--src/api/endpoints/posts/polls/vote.ts101
-rw-r--r--src/api/endpoints/posts/replies.ts6
-rw-r--r--src/api/endpoints/posts/reposts.ts6
-rw-r--r--src/api/endpoints/posts/search.ts6
-rw-r--r--src/api/endpoints/posts/show.ts6
-rw-r--r--src/api/endpoints/posts/timeline.ts6
-rw-r--r--src/api/endpoints/username/available.ts6
-rw-r--r--src/api/endpoints/users.ts79
-rw-r--r--src/api/endpoints/users/followers.ts6
-rw-r--r--src/api/endpoints/users/following.ts6
-rw-r--r--src/api/endpoints/users/posts.ts6
-rw-r--r--src/api/endpoints/users/recommendation.ts6
-rw-r--r--src/api/endpoints/users/search.ts6
-rw-r--r--src/api/endpoints/users/search_by_username.ts6
-rw-r--r--src/api/endpoints/users/show.ts6
69 files changed, 468 insertions, 733 deletions
diff --git a/src/api/endpoints/aggregation/posts/like.ts b/src/api/endpoints/aggregation/posts/like.ts
index 38ed7e6e16..7eaf0335c7 100644
--- a/src/api/endpoints/aggregation/posts/like.ts
+++ b/src/api/endpoints/aggregation/posts/like.ts
@@ -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);
diff --git a/src/api/endpoints/aggregation/posts/likes.ts b/src/api/endpoints/aggregation/posts/likes.ts
index 55fe077f64..c39de7d0cb 100644
--- a/src/api/endpoints/aggregation/posts/likes.ts
+++ b/src/api/endpoints/aggregation/posts/likes.ts
@@ -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');
diff --git a/src/api/endpoints/aggregation/posts/reply.ts b/src/api/endpoints/aggregation/posts/reply.ts
index 1f936bbc2f..541bc594d4 100644
--- a/src/api/endpoints/aggregation/posts/reply.ts
+++ b/src/api/endpoints/aggregation/posts/reply.ts
@@ -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);
diff --git a/src/api/endpoints/aggregation/posts/repost.ts b/src/api/endpoints/aggregation/posts/repost.ts
index e4a1bf7c7b..823a6ed9e3 100644
--- a/src/api/endpoints/aggregation/posts/repost.ts
+++ b/src/api/endpoints/aggregation/posts/repost.ts
@@ -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);
diff --git a/src/api/endpoints/aggregation/users/followers.ts b/src/api/endpoints/aggregation/users/followers.ts
index 9336a102f1..cc217643cf 100644
--- a/src/api/endpoints/aggregation/users/followers.ts
+++ b/src/api/endpoints/aggregation/users/followers.ts
@@ -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');
diff --git a/src/api/endpoints/aggregation/users/following.ts b/src/api/endpoints/aggregation/users/following.ts
index d468229158..75e0c74694 100644
--- a/src/api/endpoints/aggregation/users/following.ts
+++ b/src/api/endpoints/aggregation/users/following.ts
@@ -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');
diff --git a/src/api/endpoints/aggregation/users/like.ts b/src/api/endpoints/aggregation/users/like.ts
index 4a932354ad..a1a3b5cd9d 100644
--- a/src/api/endpoints/aggregation/users/like.ts
+++ b/src/api/endpoints/aggregation/users/like.ts
@@ -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);
diff --git a/src/api/endpoints/aggregation/users/post.ts b/src/api/endpoints/aggregation/users/post.ts
index b62dd6ec98..a4d9e2ddfb 100644
--- a/src/api/endpoints/aggregation/users/post.ts
+++ b/src/api/endpoints/aggregation/users/post.ts
@@ -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);
diff --git a/src/api/endpoints/app/create.ts b/src/api/endpoints/app/create.ts
index adbb205f62..a357280aab 100644
--- a/src/api/endpoints/app/create.ts
+++ b/src/api/endpoints/app/create.ts
@@ -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');
diff --git a/src/api/endpoints/app/name_id/available.ts b/src/api/endpoints/app/name_id/available.ts
index 6af18ae83c..64171fc73f 100644
--- a/src/api/endpoints/app/name_id/available.ts
+++ b/src/api/endpoints/app/name_id/available.ts
@@ -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');
diff --git a/src/api/endpoints/app/show.ts b/src/api/endpoints/app/show.ts
index 6b6e4f010c..e0ff02cf4b 100644
--- a/src/api/endpoints/app/show.ts
+++ b/src/api/endpoints/app/show.ts
@@ -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');
diff --git a/src/api/endpoints/auth/accept.ts b/src/api/endpoints/auth/accept.ts
index 2c104ef1c6..7fc4a8a878 100644
--- a/src/api/endpoints/auth/accept.ts
+++ b/src/api/endpoints/auth/accept.ts
@@ -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');
diff --git a/src/api/endpoints/auth/session/generate.ts b/src/api/endpoints/auth/session/generate.ts
index 6e730123c1..ceb3079ae2 100644
--- a/src/api/endpoints/auth/session/generate.ts
+++ b/src/api/endpoints/auth/session/generate.ts
@@ -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');
diff --git a/src/api/endpoints/auth/session/show.ts b/src/api/endpoints/auth/session/show.ts
index 55641929d8..77f8c5dc9e 100644
--- a/src/api/endpoints/auth/session/show.ts
+++ b/src/api/endpoints/auth/session/show.ts
@@ -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');
diff --git a/src/api/endpoints/auth/session/userkey.ts b/src/api/endpoints/auth/session/userkey.ts
index fdb8c26d4e..121c9ce269 100644
--- a/src/api/endpoints/auth/session/userkey.ts
+++ b/src/api/endpoints/auth/session/userkey.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -51,62 +49,61 @@ import serialize from '../../../serializers/user';
* @param {any} params
* @return {Promise<any>}
*/
-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');
+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');
- // Lookup app
- const app = await App.findOne({
- secret: appSecret
- });
+ // Lookup app
+ const app = await App.findOne({
+ secret: appSecret
+ });
- if (app == null) {
- return rej('app not found');
- }
+ if (app == null) {
+ return rej('app not found');
+ }
- // Get 'token' parameter
- const [token, tokenErr] = it(params.token).expect.string().required().qed();
- if (tokenErr) return rej('invalid token param');
+ // Get 'token' parameter
+ const [token, tokenErr] = it(params.token).expect.string().required().qed();
+ if (tokenErr) return rej('invalid token param');
- // Fetch token
- const session = await AuthSess
- .findOne({
- token: token,
- app_id: app._id
- });
+ // Fetch token
+ const session = await AuthSess
+ .findOne({
+ token: token,
+ app_id: app._id
+ });
- if (session === null) {
- return rej('session not found');
- }
+ if (session === null) {
+ return rej('session not found');
+ }
- if (session.user_id == null) {
- return rej('this session is not allowed yet');
- }
+ if (session.user_id == null) {
+ return rej('this session is not allowed yet');
+ }
- // Lookup access token
- const accessToken = await AccessToken.findOne({
- app_id: app._id,
- user_id: session.user_id
- });
+ // Lookup access token
+ const accessToken = await AccessToken.findOne({
+ app_id: app._id,
+ user_id: session.user_id
+ });
- // Delete session
+ // Delete session
- /* https://github.com/Automattic/monk/issues/178
- AuthSess.deleteOne({
- _id: session._id
- });
- */
- AuthSess.remove({
- _id: session._id
- });
+ /* https://github.com/Automattic/monk/issues/178
+ AuthSess.deleteOne({
+ _id: session._id
+ });
+ */
+ AuthSess.remove({
+ _id: session._id
+ });
- // Response
- res({
- access_token: accessToken.token,
- user: await serialize(session.user_id, null, {
- detail: true
- })
- });
+ // Response
+ res({
+ access_token: accessToken.token,
+ user: await serialize(session.user_id, null, {
+ detail: true
+ })
});
+});
diff --git a/src/api/endpoints/drive.ts b/src/api/endpoints/drive.ts
index d73de67f44..41ad6301d7 100644
--- a/src/api/endpoints/drive.ts
+++ b/src/api/endpoints/drive.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -12,29 +10,28 @@ import DriveFile from '../models/drive-file';
* @param {any} user
* @return {Promise<any>}
*/
-module.exports = (params, user) =>
- new Promise(async (res, rej) => {
- // Calculate drive usage
- const usage = ((await DriveFile
- .aggregate([
- { $match: { user_id: user._id } },
- {
- $project: {
- datasize: true
- }
- },
- {
- $group: {
- _id: null,
- usage: { $sum: '$datasize' }
- }
+module.exports = (params, user) => new Promise(async (res, rej) => {
+ // Calculate drive usage
+ const usage = ((await DriveFile
+ .aggregate([
+ { $match: { user_id: user._id } },
+ {
+ $project: {
+ datasize: true
+ }
+ },
+ {
+ $group: {
+ _id: null,
+ usage: { $sum: '$datasize' }
}
- ]))[0] || {
- usage: 0
- }).usage;
+ }
+ ]))[0] || {
+ usage: 0
+ }).usage;
- res({
- capacity: user.drive_capacity,
- usage: usage
- });
+ res({
+ capacity: user.drive_capacity,
+ usage: usage
});
+});
diff --git a/src/api/endpoints/drive/files.ts b/src/api/endpoints/drive/files.ts
index 2600e613e6..16606d54b2 100644
--- a/src/api/endpoints/drive/files.ts
+++ b/src/api/endpoints/drive/files.ts
@@ -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');
diff --git a/src/api/endpoints/drive/files/create.ts b/src/api/endpoints/drive/files/create.ts
index 7efd149813..c2dc18f33d 100644
--- a/src/api/endpoints/drive/files/create.ts
+++ b/src/api/endpoints/drive/files/create.ts
@@ -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;
diff --git a/src/api/endpoints/drive/files/find.ts b/src/api/endpoints/drive/files/find.ts
index 393b8c5b98..f2819692f1 100644
--- a/src/api/endpoints/drive/files/find.ts
+++ b/src/api/endpoints/drive/files/find.ts
@@ -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');
diff --git a/src/api/endpoints/drive/files/show.ts b/src/api/endpoints/drive/files/show.ts
index 2024a56ca6..d439ec49f3 100644
--- a/src/api/endpoints/drive/files/show.ts
+++ b/src/api/endpoints/drive/files/show.ts
@@ -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');
diff --git a/src/api/endpoints/drive/files/update.ts b/src/api/endpoints/drive/files/update.ts
index 595d501658..1a75a15daf 100644
--- a/src/api/endpoints/drive/files/update.ts
+++ b/src/api/endpoints/drive/files/update.ts
@@ -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');
diff --git a/src/api/endpoints/drive/files/upload_from_url.ts b/src/api/endpoints/drive/files/upload_from_url.ts
index b6f4789317..7042b1e020 100644
--- a/src/api/endpoints/drive/files/upload_from_url.ts
+++ b/src/api/endpoints/drive/files/upload_from_url.ts
@@ -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();
diff --git a/src/api/endpoints/drive/folders.ts b/src/api/endpoints/drive/folders.ts
index 45c0117ba0..8e04aa711e 100644
--- a/src/api/endpoints/drive/folders.ts
+++ b/src/api/endpoints/drive/folders.ts
@@ -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');
diff --git a/src/api/endpoints/drive/folders/create.ts b/src/api/endpoints/drive/folders/create.ts
index d327572af7..f2f788fe41 100644
--- a/src/api/endpoints/drive/folders/create.ts
+++ b/src/api/endpoints/drive/folders/create.ts
@@ -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');
diff --git a/src/api/endpoints/drive/folders/find.ts b/src/api/endpoints/drive/folders/find.ts
index 041e9ccb2a..27f667b21c 100644
--- a/src/api/endpoints/drive/folders/find.ts
+++ b/src/api/endpoints/drive/folders/find.ts
@@ -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');
diff --git a/src/api/endpoints/drive/folders/show.ts b/src/api/endpoints/drive/folders/show.ts
index 3b3ed41719..ea9a56d7d5 100644
--- a/src/api/endpoints/drive/folders/show.ts
+++ b/src/api/endpoints/drive/folders/show.ts
@@ -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');
diff --git a/src/api/endpoints/drive/folders/update.ts b/src/api/endpoints/drive/folders/update.ts
index 81d414354c..982b44a5f9 100644
--- a/src/api/endpoints/drive/folders/update.ts
+++ b/src/api/endpoints/drive/folders/update.ts
@@ -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');
diff --git a/src/api/endpoints/drive/stream.ts b/src/api/endpoints/drive/stream.ts
index 95a7584b15..69848825a5 100644
--- a/src/api/endpoints/drive/stream.ts
+++ b/src/api/endpoints/drive/stream.ts
@@ -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');
diff --git a/src/api/endpoints/following/create.ts b/src/api/endpoints/following/create.ts
index 0edc122b94..7991f5fd97 100644
--- a/src/api/endpoints/following/create.ts
+++ b/src/api/endpoints/following/create.ts
@@ -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
diff --git a/src/api/endpoints/following/delete.ts b/src/api/endpoints/following/delete.ts
index 7f0e908068..84b1efd0fc 100644
--- a/src/api/endpoints/following/delete.ts
+++ b/src/api/endpoints/following/delete.ts
@@ -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
diff --git a/src/api/endpoints/i.ts b/src/api/endpoints/i.ts
index df8c0d0e00..0e5efdb984 100644
--- a/src/api/endpoints/i.ts
+++ b/src/api/endpoints/i.ts
@@ -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,
diff --git a/src/api/endpoints/i/appdata/get.ts b/src/api/endpoints/i/appdata/get.ts
index 7f1bdf0713..ccd8202531 100644
--- a/src/api/endpoints/i/appdata/get.ts
+++ b/src/api/endpoints/i/appdata/get.ts
@@ -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) {
diff --git a/src/api/endpoints/i/appdata/set.ts b/src/api/endpoints/i/appdata/set.ts
index 57001f4e8b..354935cb4c 100644
--- a/src/api/endpoints/i/appdata/set.ts
+++ b/src/api/endpoints/i/appdata/set.ts
@@ -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');
diff --git a/src/api/endpoints/i/authorized_apps.ts b/src/api/endpoints/i/authorized_apps.ts
index fb56a107e7..ed3670c7da 100644
--- a/src/api/endpoints/i/authorized_apps.ts
+++ b/src/api/endpoints/i/authorized_apps.ts
@@ -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');
diff --git a/src/api/endpoints/i/favorites.ts b/src/api/endpoints/i/favorites.ts
index c04d318379..11de625be5 100644
--- a/src/api/endpoints/i/favorites.ts
+++ b/src/api/endpoints/i/favorites.ts
@@ -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');
diff --git a/src/api/endpoints/i/notifications.ts b/src/api/endpoints/i/notifications.ts
index 4f4f0780b0..e6c6558fb1 100644
--- a/src/api/endpoints/i/notifications.ts
+++ b/src/api/endpoints/i/notifications.ts
@@ -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();
diff --git a/src/api/endpoints/i/signin_history.ts b/src/api/endpoints/i/signin_history.ts
index eb8fc8c23f..d549f682cb 100644
--- a/src/api/endpoints/i/signin_history.ts
+++ b/src/api/endpoints/i/signin_history.ts
@@ -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');
diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts
index b0c14777ef..1895d28375 100644
--- a/src/api/endpoints/i/update.ts
+++ b/src/api/endpoints/i/update.ts
@@ -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');
diff --git a/src/api/endpoints/messaging/history.ts b/src/api/endpoints/messaging/history.ts
index 07ad6e0f22..73d7af77a5 100644
--- a/src/api/endpoints/messaging/history.ts
+++ b/src/api/endpoints/messaging/history.ts
@@ -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');
diff --git a/src/api/endpoints/messaging/messages.ts b/src/api/endpoints/messaging/messages.ts
index 671ed27966..40fd0cf047 100644
--- a/src/api/endpoints/messaging/messages.ts
+++ b/src/api/endpoints/messaging/messages.ts
@@ -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');
diff --git a/src/api/endpoints/messaging/messages/create.ts b/src/api/endpoints/messaging/messages/create.ts
index dbe7f617fa..81968c8979 100644
--- a/src/api/endpoints/messaging/messages/create.ts
+++ b/src/api/endpoints/messaging/messages/create.ts
@@ -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');
diff --git a/src/api/endpoints/messaging/unread.ts b/src/api/endpoints/messaging/unread.ts
index faba171bdc..40bc83fe1c 100644
--- a/src/api/endpoints/messaging/unread.ts
+++ b/src/api/endpoints/messaging/unread.ts
@@ -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,
diff --git a/src/api/endpoints/meta.ts b/src/api/endpoints/meta.ts
index 5fd9c20c5a..ea2a8206ad 100644
--- a/src/api/endpoints/meta.ts
+++ b/src/api/endpoints/meta.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -40,13 +38,12 @@ import config from '../../conf';
* @param {any} params
* @return {Promise<any>}
*/
-module.exports = (params) =>
- new Promise(async (res, rej) => {
- const commit = await prominence(git).getLastCommit();
+module.exports = (params) => new Promise(async (res, rej) => {
+ const commit = await prominence(git).getLastCommit();
- res({
- maintainer: config.maintainer,
- commit: commit.shortHash,
- secure: config.https.enable
- });
+ res({
+ maintainer: config.maintainer,
+ commit: commit.shortHash,
+ secure: config.https.enable
});
+});
diff --git a/src/api/endpoints/my/apps.ts b/src/api/endpoints/my/apps.ts
index 2466a47ce4..f16be81d0c 100644
--- a/src/api/endpoints/my/apps.ts
+++ b/src/api/endpoints/my/apps.ts
@@ -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');
diff --git a/src/api/endpoints/notifications/mark_as_read.ts b/src/api/endpoints/notifications/mark_as_read.ts
index 6e75927cfa..703562fecd 100644
--- a/src/api/endpoints/notifications/mark_as_read.ts
+++ b/src/api/endpoints/notifications/mark_as_read.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -15,36 +13,35 @@ import event from '../../event';
* @param {any} user
* @return {Promise<any>}
*/
-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');
+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');
- // Get notification
- const notification = await Notification
- .findOne({
- _id: notificationId,
- i: user._id
- });
+ // Get notification
+ const notification = await Notification
+ .findOne({
+ _id: notificationId,
+ i: user._id
+ });
- if (notification === null) {
- return rej('notification-not-found');
- }
+ if (notification === null) {
+ return rej('notification-not-found');
+ }
- // Update
- notification.is_read = true;
- Notification.update({ _id: notification._id }, {
- $set: {
- is_read: true
- }
- });
+ // Update
+ notification.is_read = true;
+ Notification.update({ _id: notification._id }, {
+ $set: {
+ is_read: true
+ }
+ });
- // Response
- res();
+ // Response
+ res();
- // Serialize
- const notificationObj = await serialize(notification);
+ // Serialize
+ const notificationObj = await serialize(notification);
- // Publish read_notification event
- event(user._id, 'read_notification', notificationObj);
- });
+ // Publish read_notification event
+ event(user._id, 'read_notification', notificationObj);
+});
diff --git a/src/api/endpoints/posts.ts b/src/api/endpoints/posts.ts
index 39548d44ae..cd2da99c25 100644
--- a/src/api/endpoints/posts.ts
+++ b/src/api/endpoints/posts.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -13,64 +11,63 @@ import serialize from '../serializers/post';
* @param {any} params
* @return {Promise<any>}
*/
-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');
+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');
- // Get 'include_reposts' parameter
- const [includeReposts, includeRepostsErr] = it(params.include_reposts).expect.boolean().default(true).qed();
- if (includeRepostsErr) return rej('invalid include_reposts param');
+ // Get 'include_reposts' parameter
+ const [includeReposts, includeRepostsErr] = it(params.include_reposts).expect.boolean().default(true).qed();
+ if (includeRepostsErr) return rej('invalid include_reposts param');
- // Get 'limit' parameter
- const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
- if (limitErr) return rej('invalid limit param');
+ // Get 'limit' parameter
+ const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed();
+ if (limitErr) return rej('invalid limit param');
- // Get 'since_id' parameter
- const [sinceId, sinceIdErr] = it(params.since_id).expect.id().qed();
- if (sinceIdErr) return rej('invalid since_id param');
+ // Get 'since_id' parameter
+ const [sinceId, sinceIdErr] = it(params.since_id).expect.id().qed();
+ if (sinceIdErr) return rej('invalid since_id param');
- // Get 'max_id' parameter
- const [maxId, maxIdErr] = it(params.max_id).expect.id().qed();
- if (maxIdErr) return rej('invalid max_id param');
+ // Get 'max_id' parameter
+ const [maxId, maxIdErr] = it(params.max_id).expect.id().qed();
+ if (maxIdErr) return rej('invalid max_id param');
- // Check if both of since_id and max_id is specified
- if (sinceId && maxId) {
- return rej('cannot set since_id and max_id');
- }
+ // Check if both of since_id and max_id is specified
+ if (sinceId && maxId) {
+ return rej('cannot set since_id and max_id');
+ }
- // Construct query
- const sort = {
- _id: -1
+ // Construct query
+ const sort = {
+ _id: -1
+ };
+ const query = {} as any;
+ if (sinceId) {
+ sort._id = 1;
+ query._id = {
+ $gt: sinceId
+ };
+ } else if (maxId) {
+ query._id = {
+ $lt: maxId
};
- const query = {} as any;
- if (sinceId) {
- sort._id = 1;
- query._id = {
- $gt: sinceId
- };
- } else if (maxId) {
- query._id = {
- $lt: maxId
- };
- }
+ }
- if (!includeReplies) {
- query.reply_to_id = null;
- }
+ if (!includeReplies) {
+ query.reply_to_id = null;
+ }
- if (!includeReposts) {
- query.repost_id = null;
- }
+ if (!includeReposts) {
+ query.repost_id = null;
+ }
- // Issue query
- const posts = await Post
- .find(query, {
- limit: limit,
- sort: sort
- });
+ // Issue query
+ const posts = await Post
+ .find(query, {
+ limit: limit,
+ sort: sort
+ });
- // Serialize
- res(await Promise.all(posts.map(async post => await serialize(post))));
- });
+ // Serialize
+ res(await Promise.all(posts.map(async post => await serialize(post))));
+});
diff --git a/src/api/endpoints/posts/context.ts b/src/api/endpoints/posts/context.ts
index 5b0a56f356..7bccecfb98 100644
--- a/src/api/endpoints/posts/context.ts
+++ b/src/api/endpoints/posts/context.ts
@@ -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');
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts
index d558cd3018..dfc9866515 100644
--- a/src/api/endpoints/posts/create.ts
+++ b/src/api/endpoints/posts/create.ts
@@ -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');
diff --git a/src/api/endpoints/posts/favorites/create.ts b/src/api/endpoints/posts/favorites/create.ts
index 45a347ebb3..7ae77778e3 100644
--- a/src/api/endpoints/posts/favorites/create.ts
+++ b/src/api/endpoints/posts/favorites/create.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -14,38 +12,37 @@ import Post from '../../../models/post';
* @param {any} user
* @return {Promise<any>}
*/
-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');
-
- // Get favoritee
- const post = await Post.findOne({
- _id: postId
- });
+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');
- if (post === null) {
- return rej('post not found');
- }
+ // Get favoritee
+ const post = await Post.findOne({
+ _id: postId
+ });
- // if already favorited
- const exist = await Favorite.findOne({
- post_id: post._id,
- user_id: user._id
- });
+ if (post === null) {
+ return rej('post not found');
+ }
- if (exist !== null) {
- return rej('already favorited');
- }
+ // if already favorited
+ const exist = await Favorite.findOne({
+ post_id: post._id,
+ user_id: user._id
+ });
- // Create favorite
- await Favorite.insert({
- created_at: new Date(),
- post_id: post._id,
- user_id: user._id
- });
+ if (exist !== null) {
+ return rej('already favorited');
+ }
- // Send response
- res();
+ // Create favorite
+ await Favorite.insert({
+ created_at: new Date(),
+ post_id: post._id,
+ user_id: user._id
});
+
+ // Send response
+ res();
+});
diff --git a/src/api/endpoints/posts/favorites/delete.ts b/src/api/endpoints/posts/favorites/delete.ts
index df11215903..437863d06c 100644
--- a/src/api/endpoints/posts/favorites/delete.ts
+++ b/src/api/endpoints/posts/favorites/delete.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -14,36 +12,35 @@ import Post from '../../../models/post';
* @param {any} user
* @return {Promise<any>}
*/
-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');
-
- // Get favoritee
- const post = await Post.findOne({
- _id: postId
- });
+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');
- if (post === null) {
- return rej('post not found');
- }
+ // Get favoritee
+ const post = await Post.findOne({
+ _id: postId
+ });
- // if already favorited
- const exist = await Favorite.findOne({
- post_id: post._id,
- user_id: user._id
- });
+ if (post === null) {
+ return rej('post not found');
+ }
- if (exist === null) {
- return rej('already not favorited');
- }
+ // if already favorited
+ const exist = await Favorite.findOne({
+ post_id: post._id,
+ user_id: user._id
+ });
- // Delete favorite
- await Favorite.deleteOne({
- _id: exist._id
- });
+ if (exist === null) {
+ return rej('already not favorited');
+ }
- // Send response
- res();
+ // Delete favorite
+ await Favorite.deleteOne({
+ _id: exist._id
});
+
+ // Send response
+ res();
+});
diff --git a/src/api/endpoints/posts/likes.ts b/src/api/endpoints/posts/likes.ts
index f299de7492..88d3a6e1de 100644
--- a/src/api/endpoints/posts/likes.ts
+++ b/src/api/endpoints/posts/likes.ts
@@ -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');
diff --git a/src/api/endpoints/posts/likes/create.ts b/src/api/endpoints/posts/likes/create.ts
index 0ae417e239..43e76d1a58 100644
--- a/src/api/endpoints/posts/likes/create.ts
+++ b/src/api/endpoints/posts/likes/create.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -16,70 +14,69 @@ import notify from '../../../common/notify';
* @param {any} user
* @return {Promise<any>}
*/
-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');
+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');
- // Get likee
- const post = await Post.findOne({
- _id: postId
- });
+ // Get likee
+ const post = await Post.findOne({
+ _id: postId
+ });
- if (post === null) {
- return rej('post not found');
- }
+ if (post === null) {
+ return rej('post not found');
+ }
- // Myself
- if (post.user_id.equals(user._id)) {
- return rej('-need-translate-');
- }
+ // Myself
+ if (post.user_id.equals(user._id)) {
+ return rej('-need-translate-');
+ }
- // if already liked
- const exist = await Like.findOne({
- post_id: post._id,
- user_id: user._id,
- deleted_at: { $exists: false }
- });
+ // if already liked
+ const exist = await Like.findOne({
+ post_id: post._id,
+ user_id: user._id,
+ deleted_at: { $exists: false }
+ });
- if (exist !== null) {
- return rej('already liked');
- }
+ if (exist !== null) {
+ return rej('already liked');
+ }
- // Create like
- await Like.insert({
- created_at: new Date(),
- post_id: post._id,
- user_id: user._id
- });
+ // Create like
+ await Like.insert({
+ created_at: new Date(),
+ post_id: post._id,
+ user_id: user._id
+ });
- // Send response
- res();
+ // Send response
+ res();
- // Increment likes count
- Post.update({ _id: post._id }, {
- $inc: {
- likes_count: 1
- }
- });
+ // Increment likes count
+ Post.update({ _id: post._id }, {
+ $inc: {
+ likes_count: 1
+ }
+ });
- // Increment user likes count
- User.update({ _id: user._id }, {
- $inc: {
- likes_count: 1
- }
- });
+ // Increment user likes count
+ User.update({ _id: user._id }, {
+ $inc: {
+ likes_count: 1
+ }
+ });
- // Increment user liked count
- User.update({ _id: post.user_id }, {
- $inc: {
- liked_count: 1
- }
- });
+ // Increment user liked count
+ User.update({ _id: post.user_id }, {
+ $inc: {
+ liked_count: 1
+ }
+ });
- // Notify
- notify(post.user_id, user._id, 'like', {
- post_id: post._id
- });
+ // Notify
+ notify(post.user_id, user._id, 'like', {
+ post_id: post._id
});
+});
diff --git a/src/api/endpoints/posts/likes/delete.ts b/src/api/endpoints/posts/likes/delete.ts
index 2b642c107f..bd2f83e21d 100644
--- a/src/api/endpoints/posts/likes/delete.ts
+++ b/src/api/endpoints/posts/likes/delete.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -16,62 +14,61 @@ import User from '../../../models/user';
* @param {any} user
* @return {Promise<any>}
*/
-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');
-
- // Get likee
- const post = await Post.findOne({
- _id: postId
- });
-
- if (post === null) {
- return rej('post not found');
- }
+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');
- // if already liked
- const exist = await Like.findOne({
- post_id: post._id,
- user_id: user._id,
- deleted_at: { $exists: false }
- });
+ // Get likee
+ const post = await Post.findOne({
+ _id: postId
+ });
- if (exist === null) {
- return rej('already not liked');
- }
+ if (post === null) {
+ return rej('post not found');
+ }
- // Delete like
- await Like.update({
- _id: exist._id
- }, {
- $set: {
- deleted_at: new Date()
- }
- });
+ // if already liked
+ const exist = await Like.findOne({
+ post_id: post._id,
+ user_id: user._id,
+ deleted_at: { $exists: false }
+ });
- // Send response
- res();
+ if (exist === null) {
+ return rej('already not liked');
+ }
- // Decrement likes count
- Post.update({ _id: post._id }, {
- $inc: {
- likes_count: -1
+ // Delete like
+ await Like.update({
+ _id: exist._id
+ }, {
+ $set: {
+ deleted_at: new Date()
}
});
- // Decrement user likes count
- User.update({ _id: user._id }, {
- $inc: {
- likes_count: -1
- }
- });
+ // Send response
+ res();
- // Decrement user liked count
- User.update({ _id: post.user_id }, {
- $inc: {
- liked_count: -1
- }
- });
+ // Decrement likes count
+ Post.update({ _id: post._id }, {
+ $inc: {
+ likes_count: -1
+ }
+ });
+
+ // Decrement user likes count
+ User.update({ _id: user._id }, {
+ $inc: {
+ likes_count: -1
+ }
+ });
+
+ // Decrement user liked count
+ User.update({ _id: post.user_id }, {
+ $inc: {
+ liked_count: -1
+ }
});
+});
diff --git a/src/api/endpoints/posts/mentions.ts b/src/api/endpoints/posts/mentions.ts
index a190b55f1b..3f54674955 100644
--- a/src/api/endpoints/posts/mentions.ts
+++ b/src/api/endpoints/posts/mentions.ts
@@ -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();
diff --git a/src/api/endpoints/posts/polls/vote.ts b/src/api/endpoints/posts/polls/vote.ts
index d0caf7da95..36d0de975b 100644
--- a/src/api/endpoints/posts/polls/vote.ts
+++ b/src/api/endpoints/posts/polls/vote.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -15,68 +13,67 @@ import notify from '../../../common/notify';
* @param {any} user
* @return {Promise<any>}
*/
-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');
+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');
- // Get votee
- const post = await Post.findOne({
- _id: postId
- });
+ // Get votee
+ const post = await Post.findOne({
+ _id: postId
+ });
- if (post === null) {
- return rej('post not found');
- }
+ if (post === null) {
+ return rej('post not found');
+ }
- if (post.poll == null) {
- return rej('poll not found');
- }
+ if (post.poll == null) {
+ return rej('poll not found');
+ }
- // Get 'choice' parameter
- const [choice, choiceError] =
- it(params.choice).expect.string()
- .required()
- .validate(c => post.poll.choices.some(x => x.id == c))
- .qed();
- if (choiceError) return rej('invalid choice param');
+ // Get 'choice' parameter
+ const [choice, choiceError] =
+ it(params.choice).expect.string()
+ .required()
+ .validate(c => post.poll.choices.some(x => x.id == c))
+ .qed();
+ if (choiceError) return rej('invalid choice param');
- // if already voted
- const exist = await Vote.findOne({
- post_id: post._id,
- user_id: user._id
- });
+ // if already voted
+ const exist = await Vote.findOne({
+ post_id: post._id,
+ user_id: user._id
+ });
- if (exist !== null) {
- return rej('already voted');
- }
+ if (exist !== null) {
+ return rej('already voted');
+ }
- // Create vote
- await Vote.insert({
- created_at: new Date(),
- post_id: post._id,
- user_id: user._id,
- choice: choice
- });
+ // Create vote
+ await Vote.insert({
+ created_at: new Date(),
+ post_id: post._id,
+ user_id: user._id,
+ choice: choice
+ });
- // Send response
- res();
+ // Send response
+ res();
- const inc = {};
- inc[`poll.choices.${findWithAttr(post.poll.choices, 'id', choice)}.votes`] = 1;
+ const inc = {};
+ inc[`poll.choices.${findWithAttr(post.poll.choices, 'id', choice)}.votes`] = 1;
- // Increment likes count
- Post.update({ _id: post._id }, {
- $inc: inc
- });
+ // Increment likes count
+ Post.update({ _id: post._id }, {
+ $inc: inc
+ });
- // Notify
- notify(post.user_id, user._id, 'poll_vote', {
- post_id: post._id,
- choice: choice
- });
+ // Notify
+ notify(post.user_id, user._id, 'poll_vote', {
+ post_id: post._id,
+ choice: choice
});
+});
function findWithAttr(array, attr, value) {
for (let i = 0; i < array.length; i += 1) {
diff --git a/src/api/endpoints/posts/replies.ts b/src/api/endpoints/posts/replies.ts
index 3f448d1632..378ba7ec2b 100644
--- a/src/api/endpoints/posts/replies.ts
+++ b/src/api/endpoints/posts/replies.ts
@@ -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');
diff --git a/src/api/endpoints/posts/reposts.ts b/src/api/endpoints/posts/reposts.ts
index 0c1fa9bbd1..fc9b56cfc4 100644
--- a/src/api/endpoints/posts/reposts.ts
+++ b/src/api/endpoints/posts/reposts.ts
@@ -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');
diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts
index 1d02f6775d..e869701a30 100644
--- a/src/api/endpoints/posts/search.ts
+++ b/src/api/endpoints/posts/search.ts
@@ -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');
diff --git a/src/api/endpoints/posts/show.ts b/src/api/endpoints/posts/show.ts
index 712ef1e160..0ff1947e98 100644
--- a/src/api/endpoints/posts/show.ts
+++ b/src/api/endpoints/posts/show.ts
@@ -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');
diff --git a/src/api/endpoints/posts/timeline.ts b/src/api/endpoints/posts/timeline.ts
index c599c4ded7..83a96e6c65 100644
--- a/src/api/endpoints/posts/timeline.ts
+++ b/src/api/endpoints/posts/timeline.ts
@@ -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');
diff --git a/src/api/endpoints/username/available.ts b/src/api/endpoints/username/available.ts
index 9a85644b69..049121d2d2 100644
--- a/src/api/endpoints/username/available.ts
+++ b/src/api/endpoints/username/available.ts
@@ -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');
diff --git a/src/api/endpoints/users.ts b/src/api/endpoints/users.ts
index 7f9fa69df8..cc4e5865a6 100644
--- a/src/api/endpoints/users.ts
+++ b/src/api/endpoints/users.ts
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies
*/
@@ -14,49 +12,48 @@ import serialize from '../serializers/user';
* @param {any} me
* @return {Promise<any>}
*/
-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');
+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');
- // Get 'since_id' parameter
- const [sinceId, sinceIdErr] = it(params.since_id).expect.id().qed();
- if (sinceIdErr) return rej('invalid since_id param');
+ // Get 'since_id' parameter
+ const [sinceId, sinceIdErr] = it(params.since_id).expect.id().qed();
+ if (sinceIdErr) return rej('invalid since_id param');
- // Get 'max_id' parameter
- const [maxId, maxIdErr] = it(params.max_id).expect.id().qed();
- if (maxIdErr) return rej('invalid max_id param');
+ // Get 'max_id' parameter
+ const [maxId, maxIdErr] = it(params.max_id).expect.id().qed();
+ if (maxIdErr) return rej('invalid max_id param');
- // Check if both of since_id and max_id is specified
- if (sinceId && maxId) {
- return rej('cannot set since_id and max_id');
- }
+ // Check if both of since_id and max_id is specified
+ if (sinceId && maxId) {
+ return rej('cannot set since_id and max_id');
+ }
- // Construct query
- const sort = {
- _id: -1
+ // Construct query
+ const sort = {
+ _id: -1
+ };
+ const query = {} as any;
+ if (sinceId) {
+ sort._id = 1;
+ query._id = {
+ $gt: sinceId
+ };
+ } else if (maxId) {
+ query._id = {
+ $lt: maxId
};
- const query = {} as any;
- if (sinceId) {
- sort._id = 1;
- query._id = {
- $gt: sinceId
- };
- } else if (maxId) {
- query._id = {
- $lt: maxId
- };
- }
+ }
- // Issue query
- const users = await User
- .find(query, {
- limit: limit,
- sort: sort
- });
+ // Issue query
+ const users = await User
+ .find(query, {
+ limit: limit,
+ sort: sort
+ });
- // Serialize
- res(await Promise.all(users.map(async user =>
- await serialize(user, me))));
- });
+ // Serialize
+ res(await Promise.all(users.map(async user =>
+ await serialize(user, me))));
+});
diff --git a/src/api/endpoints/users/followers.ts b/src/api/endpoints/users/followers.ts
index 011a1c70ce..e593854e81 100644
--- a/src/api/endpoints/users/followers.ts
+++ b/src/api/endpoints/users/followers.ts
@@ -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');
diff --git a/src/api/endpoints/users/following.ts b/src/api/endpoints/users/following.ts
index df5c058354..00baedbf87 100644
--- a/src/api/endpoints/users/following.ts
+++ b/src/api/endpoints/users/following.ts
@@ -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');
diff --git a/src/api/endpoints/users/posts.ts b/src/api/endpoints/users/posts.ts
index 78f91b16c5..2832c5c6c3 100644
--- a/src/api/endpoints/users/posts.ts
+++ b/src/api/endpoints/users/posts.ts
@@ -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');
diff --git a/src/api/endpoints/users/recommendation.ts b/src/api/endpoints/users/recommendation.ts
index c37ae4c978..f502f41269 100644
--- a/src/api/endpoints/users/recommendation.ts
+++ b/src/api/endpoints/users/recommendation.ts
@@ -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');
diff --git a/src/api/endpoints/users/search.ts b/src/api/endpoints/users/search.ts
index 3fb08b0a35..b21d8a2399 100644
--- a/src/api/endpoints/users/search.ts
+++ b/src/api/endpoints/users/search.ts
@@ -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');
diff --git a/src/api/endpoints/users/search_by_username.ts b/src/api/endpoints/users/search_by_username.ts
index 540c48e7ce..4071f341f2 100644
--- a/src/api/endpoints/users/search_by_username.ts
+++ b/src/api/endpoints/users/search_by_username.ts
@@ -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');
diff --git a/src/api/endpoints/users/show.ts b/src/api/endpoints/users/show.ts
index 9997d2ba03..d35bfbae20 100644
--- a/src/api/endpoints/users/show.ts
+++ b/src/api/endpoints/users/show.ts
@@ -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');