diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2022-06-25 18:26:31 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2022-06-25 18:26:31 +0900 |
| commit | 58e83f8e4f634bfd95a3afc847a875413120c301 (patch) | |
| tree | 9882477cac227f59c904900b0271ac1bc4e6f517 /packages/backend/src/server/api/index.ts | |
| parent | refactor(client): extract tooltip logic of chart (diff) | |
| download | misskey-58e83f8e4f634bfd95a3afc847a875413120c301.tar.gz misskey-58e83f8e4f634bfd95a3afc847a875413120c301.tar.bz2 misskey-58e83f8e4f634bfd95a3afc847a875413120c301.zip | |
feat: allow GET for some endpoints
Resolve #8263
Diffstat (limited to 'packages/backend/src/server/api/index.ts')
| -rw-r--r-- | packages/backend/src/server/api/index.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index 02bec31b17..83ece51f51 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -8,6 +8,8 @@ import multer from '@koa/multer'; import bodyParser from 'koa-bodyparser'; import cors from '@koa/cors'; +import { Instances, AccessTokens, Users } from '@/models/index.js'; +import config from '@/config/index.js'; import endpoints from './endpoints.js'; import handler from './api-handler.js'; import signup from './private/signup.js'; @@ -16,8 +18,6 @@ import signupPending from './private/signup-pending.js'; import discord from './service/discord.js'; import github from './service/github.js'; import twitter from './service/twitter.js'; -import { Instances, AccessTokens, Users } from '@/models/index.js'; -import config from '@/config/index.js'; // Init app const app = new Koa(); @@ -56,11 +56,24 @@ for (const endpoint of endpoints) { if (endpoint.meta.requireFile) { router.post(`/${endpoint.name}`, upload.single('file'), handler.bind(null, endpoint)); } else { + // 後方互換性のため if (endpoint.name.includes('-')) { - // 後方互換性のため router.post(`/${endpoint.name.replace(/-/g, '_')}`, handler.bind(null, endpoint)); + + if (endpoint.meta.allowGet) { + router.get(`/${endpoint.name.replace(/-/g, '_')}`, handler.bind(null, endpoint)); + } else { + router.get(`/${endpoint.name.replace(/-/g, '_')}`, async ctx => { ctx.status = 405; }); + } } + router.post(`/${endpoint.name}`, handler.bind(null, endpoint)); + + if (endpoint.meta.allowGet) { + router.get(`/${endpoint.name}`, handler.bind(null, endpoint)); + } else { + router.get(`/${endpoint.name}`, async ctx => { ctx.status = 405; }); + } } } |