refactor: use ajv instead of cafy (#8324)

* wip

* wip

* Update abuse-user-reports.ts

* Update files.ts

* Update list-remote.ts

* Update list.ts

* Update show-users.ts

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update update.ts

* Update search.ts

* Update reactions.ts

* Update search.ts

* wip

* wip

* wip

* wip

* Update update.ts

* Update relation.ts

* Update available.ts

* wip

* wip

* wip

* Update packages/backend/src/server/api/define.ts

Co-authored-by: Johann150 <johann.galle@protonmail.com>

* Update define.ts

* Update define.ts

* typo

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update update.ts

* wip

* Update signup.ts

* Update call.ts

* minimum for limit

* type

* remove needless annotation

* wip

* Update signup.ts

* wip

* wip

* fix

* Update create.ts

Co-authored-by: Johann150 <johann.galle@protonmail.com>
This commit is contained in:
syuilo
2022-02-19 14:05:32 +09:00
committed by GitHub
parent 59785ea04c
commit 510de87607
320 changed files with 4395 additions and 5939 deletions

View File

@@ -1,31 +1,24 @@
import $ from 'cafy';
import define from '../../define';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { activeUsersChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'users'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(activeUsersChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
},
// TODO: response definition
required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await activeUsersChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
export default define(meta, paramDef, async (ps) => {
return await activeUsersChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});

View File

@@ -1,31 +1,24 @@
import $ from 'cafy';
import define from '../../define';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { apRequestChart } from '@/services/chart/index';
export const meta = {
tags: ['charts'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(apRequestChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
},
// TODO: response definition
required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await apRequestChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
export default define(meta, paramDef, async (ps) => {
return await apRequestChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});

View File

@@ -1,31 +1,24 @@
import $ from 'cafy';
import define from '../../define';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { driveChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'drive'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(driveChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
},
// TODO: response definition
required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await driveChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
export default define(meta, paramDef, async (ps) => {
return await driveChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});

View File

@@ -1,31 +1,24 @@
import $ from 'cafy';
import define from '../../define';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { federationChart } from '@/services/chart/index';
export const meta = {
tags: ['charts'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(federationChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
},
// TODO: response definition
required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await federationChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
export default define(meta, paramDef, async (ps) => {
return await federationChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});

View File

@@ -1,35 +1,25 @@
import $ from 'cafy';
import define from '../../define';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { hashtagChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'hashtags'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(hashtagChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
tag: {
validator: $.str,
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
tag: { type: 'string' },
},
// TODO: response definition
required: ['span', 'tag'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await hashtagChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.tag);
export default define(meta, paramDef, async (ps) => {
return await hashtagChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.tag);
});

View File

@@ -1,35 +1,25 @@
import $ from 'cafy';
import define from '../../define';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { instanceChart } from '@/services/chart/index';
export const meta = {
tags: ['charts'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(instanceChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
host: {
validator: $.str,
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
host: { type: 'string' },
},
// TODO: response definition
required: ['span', 'host'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await instanceChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.host);
export default define(meta, paramDef, async (ps) => {
return await instanceChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.host);
});

View File

@@ -1,31 +1,24 @@
import $ from 'cafy';
import define from '../../define';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { notesChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'notes'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(notesChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
},
// TODO: response definition
required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await notesChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
export default define(meta, paramDef, async (ps) => {
return await notesChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});

View File

@@ -1,36 +1,25 @@
import $ from 'cafy';
import define from '../../../define';
import { ID } from '@/misc/cafy-id';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { perUserDriveChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'drive', 'users'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(perUserDriveChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
userId: {
validator: $.type(ID),
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
userId: { type: 'string', format: 'misskey:id' },
},
// TODO: response definition
required: ['span', 'userId'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await perUserDriveChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
export default define(meta, paramDef, async (ps) => {
return await perUserDriveChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
});

View File

@@ -1,36 +1,25 @@
import $ from 'cafy';
import define from '../../../define';
import { ID } from '@/misc/cafy-id';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { perUserFollowingChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'users', 'following'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(perUserFollowingChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
userId: {
validator: $.type(ID),
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
userId: { type: 'string', format: 'misskey:id' },
},
// TODO: response definition
required: ['span', 'userId'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await perUserFollowingChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
export default define(meta, paramDef, async (ps) => {
return await perUserFollowingChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
});

View File

@@ -1,36 +1,25 @@
import $ from 'cafy';
import define from '../../../define';
import { ID } from '@/misc/cafy-id';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { perUserNotesChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'users', 'notes'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(perUserNotesChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
userId: {
validator: $.type(ID),
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
userId: { type: 'string', format: 'misskey:id' },
},
// TODO: response definition
required: ['span', 'userId'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await perUserNotesChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
export default define(meta, paramDef, async (ps) => {
return await perUserNotesChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
});

View File

@@ -1,36 +1,25 @@
import $ from 'cafy';
import define from '../../../define';
import { ID } from '@/misc/cafy-id';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { perUserReactionsChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'users', 'reactions'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(perUserReactionsChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
userId: {
validator: $.type(ID),
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
userId: { type: 'string', format: 'misskey:id' },
},
// TODO: response definition
required: ['span', 'userId'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await perUserReactionsChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
export default define(meta, paramDef, async (ps) => {
return await perUserReactionsChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
});

View File

@@ -1,31 +1,24 @@
import $ from 'cafy';
import define from '../../define';
import { convertLog } from '@/services/chart/core';
import { getJsonSchema } from '@/services/chart/core';
import { usersChart } from '@/services/chart/index';
export const meta = {
tags: ['charts', 'users'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
res: getJsonSchema(usersChart.schema),
} as const;
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
const paramDef = {
type: 'object',
properties: {
span: { type: 'string', enum: ['day', 'hour'] },
limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
offset: { type: 'integer', nullable: true, default: null },
},
// TODO: response definition
required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
return await usersChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
export default define(meta, paramDef, async (ps) => {
return await usersChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});