|
1 | 1 | const assert = require('assert'); |
2 | 2 | const querystring = require('querystring'); |
3 | 3 |
|
4 | | -const Router = require('koa-trie-router'); |
5 | 4 | const getCors = require('@koa/cors'); |
6 | 5 |
|
| 6 | +const Router = require('../router'); |
7 | 7 | const { homepage, version } = require('../../package.json'); |
8 | 8 | const { |
9 | 9 | getAuthorization, getUserinfo, getToken, getCertificates, getRegistration, getRevocation, |
@@ -83,7 +83,7 @@ module.exports = function initializeApp() { |
83 | 83 | }; |
84 | 84 | const del = (name, route, ...stack) => { |
85 | 85 | routerAssert(name, route, ...stack); |
86 | | - router.del(route, namedRoute.bind(undefined, name), ensureOIDC, ...stack); |
| 86 | + router.delete(route, namedRoute.bind(undefined, name), ensureOIDC, ...stack); |
87 | 87 | }; |
88 | 88 | const put = (name, route, ...stack) => { |
89 | 89 | routerAssert(name, route, ...stack); |
@@ -244,17 +244,9 @@ module.exports = function initializeApp() { |
244 | 244 | app.use(error(this)); |
245 | 245 | app.use(async (ctx, next) => { |
246 | 246 | await next(); |
247 | | - if (!router.isImplementedMethod(ctx.method)) { |
248 | | - throw new InvalidRequest('not implemented', 501); |
249 | | - } |
250 | | - |
251 | 247 | if (ctx.status === 404 && ctx.message === 'Not Found') { |
252 | | - throw new InvalidRequest('unrecognized route', 404); |
253 | | - } |
254 | | - |
255 | | - if (ctx.status === 405) { |
256 | | - throw new InvalidRequest(`method ${ctx.method} not allowed on ${ctx.path}`, 405); |
| 248 | + throw new InvalidRequest(`unrecognized route or not allowed method (${ctx.method} on ${ctx.path})`, 404); |
257 | 249 | } |
258 | 250 | }); |
259 | | - app.use(router.middleware()); |
| 251 | + app.use(router.routes()); |
260 | 252 | }; |
0 commit comments