waibu 2.19.1 → 2.21.0

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.
@@ -17,5 +17,9 @@
17
17
  "httpReq%s%s%s%s": "%s %s%s from IP %s",
18
18
  "httpReqExt%s": ", content length: %s",
19
19
  "internalServerError": "Internal Server Error",
20
- "pageNotFound": "Page Not Found"
20
+ "pageNotFound": "Page Not Found",
21
+ "pageNotFoundDesc": "Sorry, the page you're looking for is nowhere to be found!",
22
+ "accessDenied": "Access Denied",
23
+ "accessDeniedDesc": "Sorry, you don't have permission to access this page or to perform this action!",
24
+ "internalServerErrorDesc": "Sorry, something went wrong on our end. Please try again later or contact support if the problem persists."
21
25
  }
@@ -17,5 +17,9 @@
17
17
  "httpReq%s%s%s%s": "%s %s:%s dari IP %s",
18
18
  "httpReqExt%s": ", panjang konten: %s",
19
19
  "internalServerError": "Kesalahan Internal Server",
20
- "pageNotFound": "Halaman Tidak Ditemukan"
20
+ "pageNotFound": "Halaman Tidak Ditemukan",
21
+ "pageNotFoundDesc": "Maaf, halaman yang akan Anda tuju tidak bisa ditemukan dimanapun!",
22
+ "accessDenied": "Akses Ditolak",
23
+ "accessDeniedDesc": "Maaf, Anda tidak memiliki izin untuk mengakses halaman ini atau melakukan tindakan ini!",
24
+ "internalServerErrorDesc": "Maaf, terjadi kesalahan di pihak kami. Silakan coba lagi nanti atau hubungi dukungan jika masalah ini terus berlanjut."
21
25
  }
package/index.js CHANGED
@@ -130,6 +130,7 @@ async function factory (pkgName) {
130
130
  fileSize: 10485760
131
131
  }
132
132
  },
133
+ exposeError: undefined,
133
134
  underPressure: false,
134
135
  forwardOpts: {
135
136
  disableRequestLogging: true,
@@ -164,8 +165,10 @@ async function factory (pkgName) {
164
165
  */
165
166
  init = async () => {
166
167
  const { isString } = this.app.lib._
168
+ const { isSet } = this.app.lib.aneka
167
169
  if (isString(this.config.log.disable)) this.config.log.disable = [this.config.log.disable]
168
170
  await collectRoutePathHandlers.call(this)
171
+ if (!isSet(this.config.exposeError)) this.config.exposeError = this.app.bajo.config.env === 'dev'
169
172
  }
170
173
 
171
174
  /**
@@ -472,7 +475,7 @@ async function factory (pkgName) {
472
475
  const { defaultsDeep } = this.app.lib.aneka
473
476
  const { isEmpty, get, trimEnd, trimStart } = this.app.lib._
474
477
  const { breakNsPath } = this.app.bajo
475
- const { query = {}, ns = this.ns, params = {}, guessHost, defaults = {}, uriEncoded } = options
478
+ const { query = {}, ns = this.ns, params = {}, guessHost, defaults = {}, uriEncoded, throwError = false } = options
476
479
 
477
480
  const plugin = this.app.getPlugin(ns)
478
481
  const cfg = plugin.config ?? {}
@@ -484,7 +487,7 @@ async function factory (pkgName) {
484
487
  if (['%', '.', '/', '?', '#'].includes(name[0]) || name.slice(1, 2) === ':') info.path = name
485
488
  else if (['~'].includes(name[0])) info.path = name.slice(1)
486
489
  else {
487
- info = breakNsPath(name, false)
490
+ info = breakNsPath(name, throwError)
488
491
  }
489
492
  if (info.path.slice(0, 2) === './') info.path = info.path.slice(2)
490
493
  if (this.routePathHandlers[info.subNs]) return (neg ? '!' : '') + this.routePathHandlers[info.subNs].handler(name, options)
package/lib/decorate.js CHANGED
@@ -7,6 +7,7 @@ async function decorate () {
7
7
  this.instance.decorateRequest('langDetector', null)
8
8
  this.instance.decorateRequest('site', null)
9
9
  this.instance.decorateRequest('ns', null)
10
+ this.instance.decorateRequest('webApp', null)
10
11
  this.instance.decorateRequest('getSetting', function (key, defValue) {
11
12
  return me.app.waibu.getSetting(key, { req: this, defValue })
12
13
  })
@@ -6,6 +6,7 @@ async function handleHome () {
6
6
  const home = req.getSetting('waibu:home', {})
7
7
  if (!home.path) throw me.error('_notFound')
8
8
  home.options = home.options ?? {}
9
+ home.options.throwError = true
9
10
  if (!home.forward) return reply.redirectTo(home.path, home.options)
10
11
  const opts = defaultsDeep(pick(req, ['params', 'query']), pick(home, ['params', 'query']))
11
12
  return reply.forwardTo(home.path, opts)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "2.19.1",
3
+ "version": "2.21.0",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-06-29
4
+
5
+ - [2.21.0] Add ```config.exposeError```
6
+
7
+ ## 2026-06-20
8
+
9
+ - [2.20.0] Add ```req.webApp``` decorator
10
+ - [2.20.0] Rename wrongly ```400.html``` to ```404.html``` template file
11
+
3
12
  ## 2026-06-19
4
13
 
5
14
  - [2.18.1] Bug fix in ```routePath()```