From 024af04b4feee698fb9d55adda6bcb3f0ddd498e Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 16 Feb 2022 22:40:50 +0900 Subject: [PATCH] wip --- packages/backend/src/misc/id-schema.ts | 3 ++ .../backend/src/server/api/endpoints/notes.ts | 44 +++++-------------- 2 files changed, 14 insertions(+), 33 deletions(-) create mode 100644 packages/backend/src/misc/id-schema.ts diff --git a/packages/backend/src/misc/id-schema.ts b/packages/backend/src/misc/id-schema.ts new file mode 100644 index 000000000..3885a3d46 --- /dev/null +++ b/packages/backend/src/misc/id-schema.ts @@ -0,0 +1,3 @@ +export const idSchema = { + type: 'string', +} as const; diff --git a/packages/backend/src/server/api/endpoints/notes.ts b/packages/backend/src/server/api/endpoints/notes.ts index 9edc6cb11..70ea458e1 100644 --- a/packages/backend/src/server/api/endpoints/notes.ts +++ b/packages/backend/src/server/api/endpoints/notes.ts @@ -1,44 +1,22 @@ -import $ from 'cafy'; -import { ID } from '@/misc/cafy-id'; import define from '../define'; import { makePaginationQuery } from '../common/make-pagination-query'; import { Notes } from '@/models/index'; +import { idSchema } from '@/misc/id-schema'; export const meta = { tags: ['notes'], params: { - local: { - validator: $.optional.bool, - }, - - reply: { - validator: $.optional.bool, - }, - - renote: { - validator: $.optional.bool, - }, - - withFiles: { - validator: $.optional.bool, - }, - - poll: { - validator: $.optional.bool, - }, - - limit: { - validator: $.optional.num.range(1, 100), - default: 10, - }, - - sinceId: { - validator: $.optional.type(ID), - }, - - untilId: { - validator: $.optional.type(ID), + type: 'object', + properties: { + local: { type: 'boolean' }, + reply: { type: 'boolean' }, + renote: { type: 'boolean' }, + withFiles: { type: 'boolean' }, + poll: { type: 'boolean' }, + limit: { type: 'number', minimum: 1, maximum: 100, default: 10 }, + sinceId: idSchema, + untilId: idSchema, }, },