waibu 2.7.0 → 2.7.1
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.
|
@@ -15,5 +15,7 @@
|
|
|
15
15
|
"middlewareDisabled%s": "Middleware '%s' is disabled",
|
|
16
16
|
"httpResp%s%s%s%s%s": "%s %s%s with a %s-status took %sms",
|
|
17
17
|
"httpReq%s%s%s%s": "%s %s%s from IP %s",
|
|
18
|
-
"httpReqExt%s": ", content length: %s"
|
|
18
|
+
"httpReqExt%s": ", content length: %s",
|
|
19
|
+
"internalServerError": "Internal Server Error",
|
|
20
|
+
"pageNotFound": "Page Not Found"
|
|
19
21
|
}
|
package/extend/bajo/intl/id.json
CHANGED
|
@@ -15,5 +15,7 @@
|
|
|
15
15
|
"middlewareDisabled%s": "Middleware '%s' dimatikan",
|
|
16
16
|
"httpResp%s%s%s%s%s": "%s %s:%s dengan status %s selama %sms",
|
|
17
17
|
"httpReq%s%s%s%s": "%s %s:%s dari IP %s",
|
|
18
|
-
"httpReqExt%s": ", panjang konten: %s"
|
|
18
|
+
"httpReqExt%s": ", panjang konten: %s",
|
|
19
|
+
"internalServerError": "Kesalahan Internal Server",
|
|
20
|
+
"pageNotFound": "Halaman Tidak Ditemukan"
|
|
19
21
|
}
|
package/lib/handle-error.js
CHANGED
|
@@ -5,7 +5,11 @@ async function error (err, req, reply) {
|
|
|
5
5
|
this.log.error(err)
|
|
6
6
|
const resp = await interceptor.call(this, 'errorHandler', err, req, reply)
|
|
7
7
|
if (resp) return resp
|
|
8
|
-
|
|
8
|
+
const payload = {
|
|
9
|
+
text: this.app.log.getErrorMessage(err),
|
|
10
|
+
title: req.t('internalServerError')
|
|
11
|
+
}
|
|
12
|
+
return writeHtml.call(this, req, reply, `${this.ns}:/lib/template/500.html`, payload)
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
async function handleError () {
|
package/lib/handle-not-found.js
CHANGED
|
@@ -5,7 +5,7 @@ export function writeHtml (req, reply, tpl, payload) {
|
|
|
5
5
|
reply.header('Content-Type', 'text/html')
|
|
6
6
|
reply.header('Content-Language', req.lang)
|
|
7
7
|
const file = getPluginFile(tpl)
|
|
8
|
-
const content = fs.readFileSync(file)
|
|
8
|
+
const content = fs.readFileSync(file, 'utf8')
|
|
9
9
|
const compiled = template(content)
|
|
10
10
|
return compiled(payload)
|
|
11
11
|
}
|
|
@@ -14,9 +14,14 @@ export async function interceptor (name, err, req, reply) {
|
|
|
14
14
|
const { get, trim } = this.app.lib._
|
|
15
15
|
let webApp = get(req, 'routeOptions.config.webApp')
|
|
16
16
|
if (!webApp) {
|
|
17
|
-
const
|
|
17
|
+
const url = req.url ?? req.raw.url
|
|
18
|
+
const [prefix] = trim(url, '/').split('/')
|
|
18
19
|
webApp = this.getPluginByPrefix(prefix, true)
|
|
19
20
|
}
|
|
21
|
+
if (!webApp) {
|
|
22
|
+
const wa = this.webApps.find(item => item.prefix === '')
|
|
23
|
+
if (wa) webApp = wa.ns
|
|
24
|
+
}
|
|
20
25
|
if (webApp) {
|
|
21
26
|
const plugin = this.app[webApp]
|
|
22
27
|
const handler = get(plugin, `webAppFactory.${name}`)
|
|
@@ -59,8 +64,11 @@ export async function notFound (err, req, reply) {
|
|
|
59
64
|
reply.code(404)
|
|
60
65
|
const resp = await interceptor.call(this, 'notFoundHandler', err, req, reply)
|
|
61
66
|
if (resp) return resp
|
|
62
|
-
const
|
|
63
|
-
|
|
67
|
+
const payload = {
|
|
68
|
+
text: req.t('notFound%s%s', req.t('route'), req.url),
|
|
69
|
+
title: req.t('pageNotFound')
|
|
70
|
+
}
|
|
71
|
+
return writeHtml.call(this, req, reply, `${this.ns}:/lib/template/404.html`, payload)
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
async function handleNotFound () {
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED