waibu 1.2.11 → 2.0.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.
- package/index.js +3 -1
- package/lib/app.js +2 -1
- package/lib/collect-route-path-handlers.js +2 -1
- package/lib/webapp-scope/is-route-disabled.js +7 -3
- package/package.json +1 -1
- /package/{bajo → extend/bajo}/hook/on-close.js +0 -0
- /package/{bajo → extend/bajo}/hook/on-ready.js +0 -0
- /package/{bajo → extend/bajo}/hook/on-request.js +0 -0
- /package/{bajo → extend/bajo}/hook/on-response.js +0 -0
- /package/{bajo → extend/bajo}/hook/on-route.js +0 -0
- /package/{bajo → extend/bajo}/intl/en-US.json +0 -0
- /package/{bajo → extend/bajo}/intl/id.json +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/layout/email.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/layout/email.id.html +0 -0
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import queryString from 'query-string'
|
|
|
15
15
|
async function factory (pkgName) {
|
|
16
16
|
const me = this
|
|
17
17
|
|
|
18
|
-
return class Waibu extends this.lib.
|
|
18
|
+
return class Waibu extends this.lib.Plugin {
|
|
19
19
|
constructor () {
|
|
20
20
|
super(pkgName, me.app)
|
|
21
21
|
this.alias = 'w'
|
|
@@ -47,6 +47,7 @@ async function factory (pkgName) {
|
|
|
47
47
|
},
|
|
48
48
|
paramsCharMap: {},
|
|
49
49
|
logRoutes: true,
|
|
50
|
+
pageTitleFormat: '%s : %s',
|
|
50
51
|
siteInfo: {
|
|
51
52
|
title: 'My Website',
|
|
52
53
|
orgName: 'My Organization'
|
|
@@ -275,6 +276,7 @@ async function factory (pkgName) {
|
|
|
275
276
|
const { isEmpty, get, trimEnd, trimStart } = this.lib._
|
|
276
277
|
const { breakNsPath } = this.app.bajo
|
|
277
278
|
const { query = {}, base = 'waibu', params = {}, guessHost } = options
|
|
279
|
+
if (isEmpty(name)) return name
|
|
278
280
|
|
|
279
281
|
const plugin = getPlugin(base)
|
|
280
282
|
const cfg = plugin.config ?? {}
|
package/lib/app.js
CHANGED
|
@@ -6,7 +6,8 @@ export async function collect (glob = 'boot.js', baseNs) {
|
|
|
6
6
|
if (!baseNs) baseNs = this.name
|
|
7
7
|
const mods = []
|
|
8
8
|
|
|
9
|
-
await eachPlugins(async function ({
|
|
9
|
+
await eachPlugins(async function ({ file }) {
|
|
10
|
+
const { name: ns, alias, config } = this
|
|
10
11
|
const mod = await importModule(file, { asHandler: true })
|
|
11
12
|
mod.prefix = get(config, 'waibu.prefix', alias)
|
|
12
13
|
if (get(config, 'intl.detectors', []).includes('path')) mod.prefix = `/:lang${mod.prefix}`
|
|
@@ -4,7 +4,8 @@ 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 () {
|
|
8
|
+
const { name: ns } = this
|
|
8
9
|
if (isEmpty(this.routePathHandlers) || !this.routePath) return undefined
|
|
9
10
|
for (const key of this.routePathHandlers) {
|
|
10
11
|
me.routePathHandlers[key] = { handler: this.routePath, ns }
|
|
@@ -10,9 +10,13 @@ async function isRouteDisabled (url, method, matchers = []) {
|
|
|
10
10
|
const items = []
|
|
11
11
|
for (let m of cloneDeep(matchers)) {
|
|
12
12
|
if (isString(m)) m = { path: m }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
try {
|
|
14
|
+
m.path = this.app.waibu.routePath(m.path)
|
|
15
|
+
m.methods = santizeMethods(m.methods)
|
|
16
|
+
items.push(m)
|
|
17
|
+
} catch (err) {
|
|
18
|
+
throw this.error(`${m.path}: ${err.message}`)
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
const matcher = items.find(i => {
|
|
18
22
|
const isMatch = outmatch(i.path)
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|