Revert "fix(api): Fix #6418 (#6442)"

This reverts commit 83ec906ee7c5d9bd42b11129f3f0b3df85287b3c.
This commit is contained in:
syuilo 2020-06-05 08:37:27 +09:00
parent 8dc2b77bbe
commit 2742abc88d
2 changed files with 11 additions and 19 deletions

View file

@ -41,9 +41,7 @@ const upload = multer({
}); });
// Init router // Init router
const router = new Router({ const router = new Router();
prefix: '/api'
});
/** /**
* Register endpoint handlers * Register endpoint handlers
@ -75,18 +73,7 @@ router.get('/v1/instance/peers', async ctx => {
ctx.body = instances.map(instance => instance.host); ctx.body = instances.map(instance => instance.host);
}); });
// Return 404 for unknown API router.post('/miauth/:session/check', async ctx => {
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({ const token = await AccessTokens.findOne({
session: ctx.params.session session: ctx.params.session
}); });
@ -108,7 +95,12 @@ miauthRouter.post('/miauth/:session/check', async ctx => {
} }
}); });
app.use(miauthRouter.routes()); // Return 404 for unknown API
//#endregion router.all('*', async ctx => {
ctx.status = 404;
});
// Register router
app.use(router.routes());
export default app; export default app;

View file

@ -17,7 +17,7 @@ import activityPub from './activitypub';
import nodeinfo from './nodeinfo'; import nodeinfo from './nodeinfo';
import wellKnown from './well-known'; import wellKnown from './well-known';
import config from '../config'; import config from '../config';
import api from './api'; import apiServer from './api';
import { sum } from '../prelude/array'; import { sum } from '../prelude/array';
import Logger from '../services/logger'; import Logger from '../services/logger';
import { program } from '../argv'; 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('/files', require('./file')));
app.use(mount('/proxy', require('./proxy'))); app.use(mount('/proxy', require('./proxy')));