From 2f5931a257c1465ae5df9612dea94fc37ea7ac8e Mon Sep 17 00:00:00 2001 From: Shigma Date: Wed, 18 Oct 2023 15:21:41 +0800 Subject: [PATCH] feat(server): change default path to `/satori` also add 405 notice for GET requests --- packages/server/src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index ace52770..151b6589 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -28,7 +28,7 @@ export interface Config { } export const Config: Schema = Schema.object({ - path: Schema.string().default(''), + path: Schema.string().default('/satori'), api: Schema.object({ // enabled: Schema.boolean().default(true), }), @@ -51,6 +51,11 @@ function transformKey(source: any, callback: (key: string) => string) { } export function apply(ctx: Context, config: Config) { + ctx.router.get(config.path + '/v1(/.+)*', async (koa) => { + koa.body = 'Please use POST method to send requests.' + koa.status = 405 + }) + ctx.router.post(config.path + '/v1/:name', async (koa) => { const method = Universal.Methods[koa.params.name] if (!method) {