Skip to content

Commit

Permalink
feat(server): change default path to /satori
Browse files Browse the repository at this point in the history
also add 405 notice for GET requests
  • Loading branch information
shigma committed Oct 18, 2023
1 parent b93f076 commit 2f5931a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface Config {
}

export const Config: Schema<Config> = Schema.object({
path: Schema.string().default(''),
path: Schema.string().default('/satori'),
api: Schema.object({
// enabled: Schema.boolean().default(true),
}),
Expand All @@ -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) {
Expand Down

0 comments on commit 2f5931a

Please sign in to comment.