From de9a5d515d9df4cda0c43ac9cc0430829cc0b5bc Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 4 Jun 2023 15:07:21 +0000 Subject: [PATCH] wip --- .../src/server/api/endpoints/antennas/show.ts | 37 ++----------------- packages/misskey-js/src/endpoints.ts | 28 ++++++++++++++ 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/antennas/show.ts b/packages/backend/src/server/api/endpoints/antennas/show.ts index ef7ed5b72c..a5bcf10ddf 100644 --- a/packages/backend/src/server/api/endpoints/antennas/show.ts +++ b/packages/backend/src/server/api/endpoints/antennas/show.ts @@ -5,46 +5,17 @@ import { AntennaEntityService } from '@/core/entities/AntennaEntityService.js'; import { DI } from '@/di-symbols.js'; import { ApiError } from '../../error.js'; -export const meta = { - tags: ['antennas', 'account'], - - requireCredential: true, - - kind: 'read:account', - - errors: { - noSuchAntenna: { - message: 'No such antenna.', - code: 'NO_SUCH_ANTENNA', - id: 'c06569fb-b025-4f23-b22d-1fcd20d2816b', - }, - }, - - res: { - type: 'object', - optional: false, nullable: false, - ref: 'Antenna', - }, -} as const; - -export const paramDef = { - type: 'object', - properties: { - antennaId: { type: 'string', format: 'misskey:id' }, - }, - required: ['antennaId'], -} as const; - // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'antennas/show'> { + name = 'antennas/show' as const; constructor( @Inject(DI.antennasRepository) private antennasRepository: AntennasRepository, private antennaEntityService: AntennaEntityService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { // Fetch the antenna const antenna = await this.antennasRepository.findOneBy({ id: ps.antennaId, @@ -52,7 +23,7 @@ export default class extends Endpoint { }); if (antenna == null) { - throw new ApiError(meta.errors.noSuchAntenna); + throw new ApiError(this.meta.errors.noSuchAntenna); } return await this.antennaEntityService.pack(antenna); diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index db7574a21c..9a14004b86 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -2114,6 +2114,34 @@ export const endpoints = { }, }], }, + 'antennas/show': { + tags: ['antennas', 'account'], + + requireCredential: true, + + kind: 'read:account', + + errors: { + noSuchAntenna: { + message: 'No such antenna.', + code: 'NO_SUCH_ANTENNA', + id: 'c06569fb-b025-4f23-b22d-1fcd20d2816b', + }, + }, + + defines: [{ + req: { + type: 'object', + properties: { + antennaId: { type: 'string', format: 'misskey:id' }, + }, + required: ['antennaId'], + }, + res: { + $ref: 'https://misskey-hub.net/api/schemas/Antenna', + }, + }], + }, //#endregion } as const satisfies { [x: string]: IEndpointMeta; };