From 174f8022eb5828db3e9af01afcf72fe7526c4c57 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 2 Nov 2018 13:47:44 +0900 Subject: Refactor --- src/server/api/endpoints/users/relation.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/server/api/endpoints/users/relation.ts') diff --git a/src/server/api/endpoints/users/relation.ts b/src/server/api/endpoints/users/relation.ts index 19643ceed0..c63ec337bf 100644 --- a/src/server/api/endpoints/users/relation.ts +++ b/src/server/api/endpoints/users/relation.ts @@ -1,6 +1,6 @@ import $ from 'cafy'; import ID, { transform, ObjectId } from '../../../../misc/cafy-id'; -import { ILocalUser, getRelation } from '../../../../models/user'; -import getParams from '../../get-params'; +import { getRelation } from '../../../../models/user'; +import define from '../../define'; export const meta = { desc: { @@ -20,13 +20,10 @@ export const meta = { } }; -export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { - const [ps, psErr] = getParams(meta, params); - if (psErr) return rej(psErr); - +export default define(meta, (ps, me) => new Promise(async (res, rej) => { const ids = Array.isArray(ps.userId) ? ps.userId : [ps.userId]; const relations = await Promise.all(ids.map(id => getRelation(me._id, id))); res(Array.isArray(ps.userId) ? relations : relations[0]); -}); +})); -- cgit v1.2.3-freya