waibu 1.0.5 → 1.0.7

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.
@@ -7,7 +7,7 @@ function routePath (name = '', { query = {}, base = 'waibuMpa', params = {}, gue
7
7
  const cfg = plugin.config ?? {}
8
8
  let info = {}
9
9
  if (name.startsWith('mailto:') || name.startsWith('tel:')) return name
10
- if (['.', '/', '?', '#'].includes(name[0]) || name.slice(1, 2) === ':') info.path = name
10
+ if (['%', '.', '/', '?', '#'].includes(name[0]) || name.slice(1, 2) === ':') info.path = name
11
11
  else if (['~'].includes(name[0])) info.path = name.slice(1)
12
12
  else {
13
13
  info = breakNsPath(name)
@@ -31,7 +31,7 @@
31
31
  "Too Many Requests": "",
32
32
  "Request Header Fields Too Large": "",
33
33
  "Unavailable For Legal Reasons": "",
34
- "Internal Server Error": "",
34
+ "Internal Server Error": "Kesalahan Internal Server",
35
35
  "Not Implemented": "",
36
36
  "Bad Gateway": "",
37
37
  "Service Unavailable": "",
package/lib/app.js CHANGED
@@ -28,6 +28,11 @@ export async function boot () {
28
28
  const mods = await collect.call(this)
29
29
  await runHook(`${this.name}:beforeAppBoot`)
30
30
  for (const m of mods) {
31
+ const disabled = this.app[m.ns].config.disabled
32
+ if (Array.isArray(disabled) && disabled.length === 1 && ['*', 'all'].includes(disabled[0])) {
33
+ this.log.warn('All %s routes are disabled by config', m.ns)
34
+ continue
35
+ }
31
36
  await runHook(`${this.name}.${m.ns}:beforeAppBoot`)
32
37
  this.log.debug('Boot app: %s', m.ns)
33
38
  await this.instance.register(async (ctx) => {
@@ -59,6 +59,7 @@ async function attachI18N (detector = [], req, reply) {
59
59
  if (req.lang) opts.lng = req.lang
60
60
  req.i18n = this.app.bajoI18N.instance.cloneInstance(opts)
61
61
  req.t = (...args) => {
62
+ // console.log(args)
62
63
  // const defNs = get(req, 'routeOptions.config.ns', this.name)
63
64
  return translate.call(this.app[defNs], req.i18n, ...args)
64
65
  }
@@ -6,9 +6,9 @@ async function errorHandler (ctx, extHandler) {
6
6
  reply.send(err.print)
7
7
  return
8
8
  }
9
- if (me.app.bajo.config.log.level === 'trace' && !['notFound', 'redirect'].includes(err.message)) console.error(err)
9
+ if (me.app.bajo.config.log.level === 'trace' && !['notfound', 'redirect'].includes(err.message.toLowerCase())) console.error(err)
10
10
  if (extHandler) return await extHandler.call(me, err, req, reply, ctx)
11
- if (err.message === 'notFound' || err.statusCode === 404) {
11
+ if (err.message.toLowerCase() === 'notfound' || err.statusCode === 404) {
12
12
  reply.code(err.statusCode)
13
13
  return
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {