Refactoring

This commit is contained in:
syuilo 2020-02-15 21:33:32 +09:00
parent 30574b63eb
commit cff0d71fef
217 changed files with 219 additions and 219 deletions

View file

@ -14,12 +14,12 @@ type Params<T extends IEndpointMeta> = {
export type Response = Record<string, any> | void;
type executor<T extends IEndpointMeta> =
(params: Params<T>, user: ILocalUser, app: App, file?: any, cleanup?: Function) =>
(params: Params<T>, user: T['requireCredential'] extends true ? ILocalUser : ILocalUser | null, app: App, file?: any, cleanup?: Function) =>
Promise<T['res'] extends undefined ? Response : SchemaType<NonNullable<T['res']>>>;
export default function <T extends IEndpointMeta>(meta: T, cb: executor<T>)
: (params: any, user: ILocalUser, app: App, file?: any) => Promise<any> {
return (params: any, user: ILocalUser, app: App, file?: any) => {
: (params: any, user: T['requireCredential'] extends true ? ILocalUser : ILocalUser | null, app: App, file?: any) => Promise<any> {
return (params: any, user: T['requireCredential'] extends true ? ILocalUser : ILocalUser | null, app: App, file?: any) => {
function cleanup() {
fs.unlink(file.path, () => {});
}

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -6,7 +6,7 @@ import { genId } from '../../../../../misc/gen-id';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -7,7 +7,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../../common/make-pagination-query';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -7,7 +7,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -7,7 +7,7 @@ import { ID } from '../../../../misc/cafy-id';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -4,7 +4,7 @@ import { Logs } from '../../../../models';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
};

View file

@ -4,7 +4,7 @@ import { createCleanRemoteFilesJob } from '../../../../../queue';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
};

View file

@ -6,7 +6,7 @@ import { DriveFiles } from '../../../../../models';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
};

View file

@ -6,7 +6,7 @@ import { DriveFiles } from '../../../../../models';
export const meta = {
tags: ['admin'],
requireCredential: false,
requireCredential: false as const,
requireModerator: true,
params: {

View file

@ -7,7 +7,7 @@ import { DriveFiles } from '../../../../../models';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -15,7 +15,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -11,7 +11,7 @@ import uploadFromUrl from '../../../../../services/drive/upload-from-url';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -11,7 +11,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -13,7 +13,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -6,7 +6,7 @@ import { DriveFiles } from '../../../../../models';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -7,7 +7,7 @@ import { ensure } from '../../../../../prelude/ensure';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -6,7 +6,7 @@ import { toPuny } from '../../../../../misc/convert-host';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -2,7 +2,7 @@ import define from '../../define';
import { getConnection } from 'typeorm';
export const meta = {
requireCredential: false,
requireCredential: false as const,
desc: {
'en-US': 'Get table stats'

View file

@ -10,7 +10,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {}

View file

@ -6,7 +6,7 @@ import { Brackets } from 'typeorm';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -11,7 +11,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireAdmin: true,
params: {

View file

@ -11,7 +11,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireAdmin: true,
params: {

View file

@ -5,7 +5,7 @@ import { insertModerationLog } from '../../../../../services/insert-moderation-l
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {}

View file

@ -4,7 +4,7 @@ import { deliverQueue } from '../../../../../queue';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -4,7 +4,7 @@ import { inboxQueue } from '../../../../../queue';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -5,7 +5,7 @@ import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '../../../
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -4,7 +4,7 @@ import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '../../../
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {}

View file

@ -6,7 +6,7 @@ import { AbuseUserReports } from '../../../../models';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -5,7 +5,7 @@ import { insertModerationLog } from '../../../../services/insert-moderation-log'
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
};

View file

@ -5,7 +5,7 @@ import { sendEmail } from '../../../../services/send-email';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -5,7 +5,7 @@ import define from '../../define';
import redis from '../../../../db/redis';
export const meta = {
requireCredential: false,
requireCredential: false as const,
desc: {
},

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -10,7 +10,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -5,7 +5,7 @@ import { Users } from '../../../../models';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -15,7 +15,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -13,7 +13,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -13,7 +13,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireAdmin: true,
params: {

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -6,7 +6,7 @@ import { insertModerationLog } from '../../../../services/insert-moderation-log'
export const meta = {
tags: ['admin'],
requireCredential: true,
requireCredential: true as const,
requireModerator: true,
params: {

View file

@ -5,7 +5,7 @@ import { Announcements, AnnouncementReads } from '../../../models';
import { makePaginationQuery } from '../common/make-pagination-query';
export const meta = {
requireCredential: false,
requireCredential: false as const,
params: {
limit: {

View file

@ -8,7 +8,7 @@ import { ApiError } from '../../error';
export const meta = {
tags: ['antennas'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:account',

View file

@ -7,7 +7,7 @@ import { Antennas } from '../../../../models';
export const meta = {
tags: ['antennas'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:account',

View file

@ -4,7 +4,7 @@ import { Antennas } from '../../../../models';
export const meta = {
tags: ['antennas', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:account',
};

View file

@ -10,7 +10,7 @@ import { ApiError } from '../../error';
export const meta = {
tags: ['account', 'notes', 'antennas'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:account',

View file

@ -7,7 +7,7 @@ import { Antennas } from '../../../../models';
export const meta = {
tags: ['antennas', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:account',

View file

@ -7,7 +7,7 @@ import { Antennas, UserLists, UserGroupJoinings } from '../../../../models';
export const meta = {
tags: ['antennas'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:account',

View file

@ -19,7 +19,7 @@ export const meta = {
'ja-JP': 'URIを指定してActivityPubオブジェクトを参照します。'
},
requireCredential: false,
requireCredential: false as const,
params: {
uri: {

View file

@ -8,7 +8,7 @@ import { unique } from '../../../../prelude/array';
export const meta = {
tags: ['app'],
requireCredential: false,
requireCredential: false as const,
desc: {
'ja-JP': 'アプリを作成します。',

View file

@ -10,7 +10,7 @@ import { ensure } from '../../../../prelude/ensure';
export const meta = {
tags: ['auth'],
requireCredential: true,
requireCredential: true as const,
secure: true,

View file

@ -9,7 +9,7 @@ import { genId } from '../../../../../misc/gen-id';
export const meta = {
tags: ['auth'],
requireCredential: false,
requireCredential: false as const,
desc: {
'ja-JP': 'アプリを認証するためのトークンを作成します。',

View file

@ -6,7 +6,7 @@ import { AuthSessions } from '../../../../../models';
export const meta = {
tags: ['auth'],
requireCredential: false,
requireCredential: false as const,
params: {
token: {

View file

@ -7,7 +7,7 @@ import { ensure } from '../../../../../prelude/ensure';
export const meta = {
tags: ['auth'],
requireCredential: false,
requireCredential: false as const,
params: {
appSecret: {

View file

@ -22,7 +22,7 @@ export const meta = {
max: 100
},
requireCredential: true,
requireCredential: true as const,
kind: 'write:blocks',

View file

@ -22,7 +22,7 @@ export const meta = {
max: 100
},
requireCredential: true,
requireCredential: true as const,
kind: 'write:blocks',

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['blocking', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:blocks',

View file

@ -6,7 +6,7 @@ import { Clips } from '../../../../models';
export const meta = {
tags: ['clips'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:account',

View file

@ -7,7 +7,7 @@ import { Clips } from '../../../../models';
export const meta = {
tags: ['clips'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:account',

View file

@ -4,7 +4,7 @@ import { Clips } from '../../../../models';
export const meta = {
tags: ['clips', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:account',
};

View file

@ -9,7 +9,7 @@ import { generateMuteQuery } from '../../common/generate-mute-query';
export const meta = {
tags: ['account', 'notes', 'clips'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:account',

View file

@ -7,7 +7,7 @@ import { Clips } from '../../../../models';
export const meta = {
tags: ['clips', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:account',

View file

@ -7,7 +7,7 @@ import { Clips } from '../../../../models';
export const meta = {
tags: ['clips'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:account',

View file

@ -10,7 +10,7 @@ export const meta = {
tags: ['drive', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -14,7 +14,7 @@ export const meta = {
tags: ['drive', 'notes'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -10,7 +10,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -15,7 +15,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
limit: {
duration: ms('1hour'),

View file

@ -16,7 +16,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:drive',

View file

@ -9,7 +9,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -4,7 +4,7 @@ import define from '../../../define';
import { DriveFiles } from '../../../../../models';
export const meta = {
requireCredential: true,
requireCredential: true as const,
tags: ['drive'],

View file

@ -15,7 +15,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -13,7 +13,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:drive',

View file

@ -17,7 +17,7 @@ export const meta = {
max: 60
},
requireCredential: true,
requireCredential: true as const,
kind: 'write:drive',

View file

@ -12,7 +12,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -16,7 +16,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:drive',

View file

@ -15,7 +15,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:drive',

View file

@ -6,7 +6,7 @@ import { DriveFolders } from '../../../../../models';
export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -14,7 +14,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -15,7 +15,7 @@ export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:drive',

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['drive'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:drive',

View file

@ -3,7 +3,7 @@ import define from '../define';
import endpoints from '../endpoints';
export const meta = {
requireCredential: false,
requireCredential: false as const,
tags: ['meta'],

View file

@ -2,7 +2,7 @@ import define from '../define';
import endpoints from '../endpoints';
export const meta = {
requireCredential: false,
requireCredential: false as const,
tags: ['meta'],

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['users'],
requireCredential: false,
requireCredential: false as const,
params: {
host: {

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['users'],
requireCredential: false,
requireCredential: false as const,
params: {
host: {

View file

@ -6,7 +6,7 @@ import { fetchMeta } from '../../../../misc/fetch-meta';
export const meta = {
tags: ['federation'],
requireCredential: false,
requireCredential: false as const,
params: {
host: {

View file

@ -6,7 +6,7 @@ import { toPuny } from '../../../../misc/convert-host';
export const meta = {
tags: ['federation'],
requireCredential: false,
requireCredential: false as const,
params: {
host: {

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['users'],
requireCredential: false,
requireCredential: false as const,
params: {
host: {

View file

@ -22,7 +22,7 @@ export const meta = {
max: 100
},
requireCredential: true,
requireCredential: true as const,
kind: 'write:following',

View file

@ -22,7 +22,7 @@ export const meta = {
max: 100
},
requireCredential: true,
requireCredential: true as const,
kind: 'write:following',

View file

@ -13,7 +13,7 @@ export const meta = {
tags: ['following', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:following',

View file

@ -14,7 +14,7 @@ export const meta = {
tags: ['following', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:following',

View file

@ -9,7 +9,7 @@ export const meta = {
tags: ['following', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'read:following'
};

View file

@ -13,7 +13,7 @@ export const meta = {
tags: ['following', 'account'],
requireCredential: true,
requireCredential: true as const,
kind: 'write:following',

View file

@ -12,7 +12,7 @@ export const meta = {
'ja-JP': '指定したリバーシの対局で投了します。'
},
requireCredential: true,
requireCredential: true as const,
params: {
gameId: {

Some files were not shown because too many files have changed in this diff Show more