Refactor API (#4770)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update description.ts

* wip
This commit is contained in:
syuilo
2019-04-23 22:35:26 +09:00
committed by GitHub
parent f31f986d66
commit 0463c6bb0f
105 changed files with 1622 additions and 808 deletions

View File

@@ -5,6 +5,7 @@ import { ApiError } from '../../error';
import { Users, Followings } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { toPunyNullable } from '../../../../misc/convert-host';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@@ -48,10 +49,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Following',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Following',
}
},
errors: {

View File

@@ -5,6 +5,7 @@ import { ApiError } from '../../error';
import { Users, Followings } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { toPunyNullable } from '../../../../misc/convert-host';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@@ -48,10 +49,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Following',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Following',
}
},
errors: {

View File

@@ -6,6 +6,7 @@ import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { Not, In } from 'typeorm';
import { Notes, Users } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
tags: ['users'],
@@ -28,9 +29,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
}
},

View File

@@ -3,6 +3,7 @@ import define from '../../../define';
import { UserLists } from '../../../../../models';
import { genId } from '../../../../../misc/gen-id';
import { UserList } from '../../../../../models/entities/user-list';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@@ -17,10 +18,16 @@ export const meta = {
kind: 'write:account',
params: {
title: {
name: {
validator: $.str.range(1, 100)
}
}
},
res: {
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'UserList',
},
};
export default define(meta, async (ps, user) => {
@@ -28,7 +35,7 @@ export default define(meta, async (ps, user) => {
id: genId(),
createdAt: new Date(),
userId: user.id,
name: ps.title,
name: ps.name,
} as UserList);
return await UserLists.pack(userList);

View File

@@ -1,5 +1,6 @@
import define from '../../../define';
import { UserLists } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@@ -13,10 +14,13 @@ export const meta = {
kind: 'read:account',
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'UserList',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'UserList',
}
},
};

View File

@@ -3,6 +3,7 @@ import { ID } from '../../../../../misc/cafy-id';
import define from '../../../define';
import { ApiError } from '../../../error';
import { UserLists } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@@ -23,7 +24,9 @@ export const meta = {
},
res: {
type: 'UserList'
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'UserList',
},
errors: {

View File

@@ -8,6 +8,7 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query'
import { Notes } from '../../../../models';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { Brackets } from 'typeorm';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@@ -119,10 +120,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@@ -3,6 +3,7 @@ import $ from 'cafy';
import define from '../../define';
import { Users, Followings } from '../../../../models';
import { generateMuteQueryForUsers } from '../../common/generate-mute-query';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@@ -28,9 +29,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
}
},
};

View File

@@ -2,6 +2,7 @@ import $ from 'cafy';
import define from '../../define';
import { Users } from '../../../../models';
import { User } from '../../../../models/entities/user';
import { bool, types } from '../../../../misc/schema';
export const meta = {
desc: {
@@ -54,9 +55,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
}
},
};

View File

@@ -6,6 +6,7 @@ import { ApiError } from '../../error';
import { ID } from '../../../../misc/cafy-id';
import { Users } from '../../../../models';
import { In } from 'typeorm';
import { bool, types } from '../../../../misc/schema';
export const meta = {
desc: {
@@ -42,7 +43,9 @@ export const meta = {
},
res: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
},
errors: {