From 3c2d94ace31c0dbbbd18606d16828df60d0392eb Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 5 Jun 2020 08:37:27 +0900 Subject: [PATCH] Revert "fix(api): Fix #6418 (#6442)" This reverts commit 83ec906ee7c5d9bd42b11129f3f0b3df85287b3c. --- src/server/api/index.ts | 26 +++++++++----------------- src/server/index.ts | 4 ++-- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/server/api/index.ts b/src/server/api/index.ts index fe38c2480..d69d92334 100644 --- a/src/server/api/index.ts +++ b/src/server/api/index.ts @@ -41,9 +41,7 @@ const upload = multer({ }); // Init router -const router = new Router({ - prefix: '/api' -}); +const router = new Router(); /** * Register endpoint handlers @@ -75,18 +73,7 @@ router.get('/v1/instance/peers', async ctx => { ctx.body = instances.map(instance => instance.host); }); -// Return 404 for unknown API -router.all('*', async ctx => { - ctx.status = 404; -}); - -// Register router -app.use(router.routes()); - -//#region miauth -const miauthRouter = new Router(); - -miauthRouter.post('/miauth/:session/check', async ctx => { +router.post('/miauth/:session/check', async ctx => { const token = await AccessTokens.findOne({ session: ctx.params.session }); @@ -108,7 +95,12 @@ miauthRouter.post('/miauth/:session/check', async ctx => { } }); -app.use(miauthRouter.routes()); -//#endregion +// Return 404 for unknown API +router.all('*', async ctx => { + ctx.status = 404; +}); + +// Register router +app.use(router.routes()); export default app; diff --git a/src/server/index.ts b/src/server/index.ts index 2f82e62aa..15e1fedc9 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -17,7 +17,7 @@ import activityPub from './activitypub'; import nodeinfo from './nodeinfo'; import wellKnown from './well-known'; import config from '../config'; -import api from './api'; +import apiServer from './api'; import { sum } from '../prelude/array'; import Logger from '../services/logger'; import { program } from '../argv'; @@ -55,7 +55,7 @@ if (config.url.startsWith('https') && !config.disableHsts) { }); } -app.use(mount(api)); +app.use(mount('/api', apiServer)); app.use(mount('/files', require('./file'))); app.use(mount('/proxy', require('./proxy')));