diff options
| author | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2023-03-09 18:37:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-10 02:37:44 +0900 |
| commit | e0b7633a7adb6f2744e1142637bbbd6ac6624031 (patch) | |
| tree | dab693ed58c315cc0d4ea3ab2348512b72ccba67 /packages/backend/src/server/ServerService.ts | |
| parent | fix(client): Solve the problem of not automatically jumping to /admin/overvie... (diff) | |
| download | sharkey-e0b7633a7adb6f2744e1142637bbbd6ac6624031.tar.gz sharkey-e0b7633a7adb6f2744e1142637bbbd6ac6624031.tar.bz2 sharkey-e0b7633a7adb6f2744e1142637bbbd6ac6624031.zip | |
enhance(backend): restore OpenAPI endpoints (#10281)
* enhance(backend): restore OpenAPI endpoints
* Update CHANGELOG.md
* version
* set max-age
* update redoc
* follow redoc documentation
---------
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Diffstat (limited to 'packages/backend/src/server/ServerService.ts')
| -rw-r--r-- | packages/backend/src/server/ServerService.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index e61383468c..3f116845cb 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -1,7 +1,9 @@ import cluster from 'node:cluster'; import * as fs from 'node:fs'; +import { fileURLToPath } from 'node:url'; import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common'; import Fastify, { FastifyInstance } from 'fastify'; +import fastifyStatic from '@fastify/static'; import { IsNull } from 'typeorm'; import { GlobalEventService } from '@/core/GlobalEventService.js'; import type { Config } from '@/config.js'; @@ -21,6 +23,9 @@ import { StreamingApiServerService } from './api/StreamingApiServerService.js'; import { WellKnownServerService } from './WellKnownServerService.js'; import { FileServerService } from './FileServerService.js'; import { ClientServerService } from './web/ClientServerService.js'; +import { OpenApiServerService } from './api/openapi/OpenApiServerService.js'; + +const _dirname = fileURLToPath(new URL('.', import.meta.url)); @Injectable() export class ServerService implements OnApplicationShutdown { @@ -42,6 +47,7 @@ export class ServerService implements OnApplicationShutdown { private userEntityService: UserEntityService, private apiServerService: ApiServerService, + private openApiServerService: OpenApiServerService, private streamingApiServerService: StreamingApiServerService, private activityPubServerService: ActivityPubServerService, private wellKnownServerService: WellKnownServerService, @@ -71,7 +77,15 @@ export class ServerService implements OnApplicationShutdown { }); } + // Register non-serving static server so that the child services can use reply.sendFile. + // `root` here is just a placeholder and each call must use its own `rootPath`. + fastify.register(fastifyStatic, { + root: _dirname, + serve: false, + }); + fastify.register(this.apiServerService.createServer, { prefix: '/api' }); + fastify.register(this.openApiServerService.createServer); fastify.register(this.fileServerService.createServer); fastify.register(this.activityPubServerService.createServer); fastify.register(this.nodeinfoServerService.createServer); |