1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-13 18:45:35 +02:00
Files
misskey/packages/backend/src/server/api/openapi/OpenApiServerService.ts
Copilot 5361a3819b fix(backend): /api-doc にアクセスできない問題を修正 (#17267)
* Initial plan

* fix: fix /api-doc returning 404 after backend minification (#17266)

Agent-Logs-Url: https://github.com/misskey-dev/misskey/sessions/8d7d0585-55da-412f-a8ee-dde1b6565026

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>

* enhance: API DocのHTMLをJSXで生成するように

* Update Changelog

* chore: remove unused imports [ci skip]

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Co-authored-by: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com>
2026-04-01 14:43:34 +09:00

36 lines
1.0 KiB
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { Inject, Injectable } from '@nestjs/common';
import type { Config } from '@/config.js';
import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js';
import { genOpenapiSpec } from './gen-spec.js';
import { ApiDocPage } from './api-doc.js';
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
@Injectable()
export class OpenApiServerService {
constructor(
@Inject(DI.config)
private config: Config,
) {
}
@bindThis
public createServer(fastify: FastifyInstance, _options: FastifyPluginOptions, done: (err?: Error) => void) {
fastify.get('/api-doc', async (_request, reply) => {
reply.header('Cache-Control', 'public, max-age=86400');
reply.type('text/html; charset=utf-8');
reply.send(await ApiDocPage());
});
fastify.get('/api.json', (_request, reply) => {
reply.header('Cache-Control', 'public, max-age=600');
reply.send(genOpenapiSpec(this.config));
});
done();
}
}