waibu 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,10 +4,10 @@ async function collectRoutePathHandlers () {
|
|
|
4
4
|
this.routePathHandlers = this.routePathHandlers ?? {}
|
|
5
5
|
const me = this
|
|
6
6
|
|
|
7
|
-
await eachPlugins(async function ({
|
|
7
|
+
await eachPlugins(async function ({ ns }) {
|
|
8
8
|
if (isEmpty(this.routePathHandlers) || !this.routePath) return undefined
|
|
9
9
|
for (const key of this.routePathHandlers) {
|
|
10
|
-
me.routePathHandlers[key] = this.routePath
|
|
10
|
+
me.routePathHandlers[key] = { handler: this.routePath, ns }
|
|
11
11
|
}
|
|
12
12
|
})
|
|
13
13
|
}
|
|
@@ -7,7 +7,7 @@ async function errorHandler (ctx, extHandler) {
|
|
|
7
7
|
return
|
|
8
8
|
}
|
|
9
9
|
if (me.app.bajo.config.env !== 'prod' && me.app.bajo.config.log.level === 'trace' &&
|
|
10
|
-
!['
|
|
10
|
+
!['_notfound', '_redirect'].includes(err.message.toLowerCase())) console.error(err)
|
|
11
11
|
if (extHandler) return await extHandler.call(me, err, req, reply, ctx)
|
|
12
12
|
if (err.message === '_notFound' || err.statusCode === 404) {
|
|
13
13
|
reply.code(err.statusCode)
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -235,10 +235,11 @@ async function factory (pkgName) {
|
|
|
235
235
|
return dir + `/${get(this.app[ns].config, 'waibu.prefix', this.app[ns].alias)}`
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
routePath = (name = '',
|
|
238
|
+
routePath = (name = '', options = {}) => {
|
|
239
239
|
const { defaultsDeep, getPlugin } = this.app.bajo
|
|
240
240
|
const { isEmpty, get, trimEnd, trimStart } = this.app.bajo.lib._
|
|
241
241
|
const { breakNsPath } = this.app.bajo
|
|
242
|
+
const { query = {}, base = 'waibu', params = {}, guessHost } = options
|
|
242
243
|
|
|
243
244
|
const plugin = getPlugin(base)
|
|
244
245
|
const cfg = plugin.config ?? {}
|
|
@@ -250,7 +251,7 @@ async function factory (pkgName) {
|
|
|
250
251
|
info = breakNsPath(name)
|
|
251
252
|
}
|
|
252
253
|
if (info.path.slice(0, 2) === './') info.path = info.path.slice(2)
|
|
253
|
-
if (this.routePathHandlers[info.subNs]) return this.routePathHandlers[info.subNs](name)
|
|
254
|
+
if (this.routePathHandlers[info.subNs]) return this.routePathHandlers[info.subNs].handler(name, options)
|
|
254
255
|
if (info.path.includes('//')) return info.path
|
|
255
256
|
|
|
256
257
|
info.path = info.path.split('/').map(p => {
|