diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-06-04 16:17:36 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-04 16:17:36 +0900 |
| commit | 83ec906ee7c5d9bd42b11129f3f0b3df85287b3c (patch) | |
| tree | 223f53d7c708e2de60941c76c3bbfcf916c61bc4 /src/server | |
| parent | Revert "chore(src/docs): Fix miauth check url" (diff) | |
| download | sharkey-83ec906ee7c5d9bd42b11129f3f0b3df85287b3c.tar.gz sharkey-83ec906ee7c5d9bd42b11129f3f0b3df85287b3c.tar.bz2 sharkey-83ec906ee7c5d9bd42b11129f3f0b3df85287b3c.zip | |
fix(api): Fix #6418 (#6442)
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/api/index.ts | 26 | ||||
| -rw-r--r-- | src/server/index.ts | 4 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/server/api/index.ts b/src/server/api/index.ts index d69d923345..fe38c24803 100644 --- a/src/server/api/index.ts +++ b/src/server/api/index.ts @@ -41,7 +41,9 @@ const upload = multer({ }); // Init router -const router = new Router(); +const router = new Router({ + prefix: '/api' +}); /** * Register endpoint handlers @@ -73,7 +75,18 @@ router.get('/v1/instance/peers', async ctx => { ctx.body = instances.map(instance => instance.host); }); -router.post('/miauth/:session/check', async ctx => { +// 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 => { const token = await AccessTokens.findOne({ session: ctx.params.session }); @@ -95,12 +108,7 @@ router.post('/miauth/:session/check', async ctx => { } }); -// Return 404 for unknown API -router.all('*', async ctx => { - ctx.status = 404; -}); - -// Register router -app.use(router.routes()); +app.use(miauthRouter.routes()); +//#endregion export default app; diff --git a/src/server/index.ts b/src/server/index.ts index 15e1fedc98..2f82e62aa6 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 apiServer from './api'; +import api 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', apiServer)); +app.use(mount(api)); app.use(mount('/files', require('./file'))); app.use(mount('/proxy', require('./proxy'))); |