waibu 1.2.5 → 1.2.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.
package/index.js CHANGED
@@ -22,7 +22,7 @@ async function factory (pkgName) {
22
22
  this.dependencies = ['bajo-logger', 'bajo-extra']
23
23
  this.config = {
24
24
  server: {
25
- address: '127.0.0.1',
25
+ host: '127.0.0.1',
26
26
  port: 7771
27
27
  },
28
28
  factory: {
@@ -188,7 +188,7 @@ async function factory (pkgName) {
188
188
  getOrigin = (req) => {
189
189
  const { isEmpty } = this.lib._
190
190
  let host = req.host
191
- if (isEmpty(host) || host === ':authority') host = `${this.config.server.address}:${this.config.server.port}`
191
+ if (isEmpty(host) || host === ':authority') host = `${this.config.server.host}:${this.config.server.port}`
192
192
  return `${req.protocol}://${host}`
193
193
  }
194
194
 
@@ -294,7 +294,7 @@ async function factory (pkgName) {
294
294
  if (options.uriEncoded) url = url.split('/').map(u => encodeURI(u)).join('/')
295
295
  info.qs = defaultsDeep({}, query, info.qs)
296
296
  if (!isEmpty(info.qs)) url += '?' + this.qs.stringify(info.qs)
297
- if (!url.startsWith('http') && guessHost) url = `http://${this.config.server.address}:${this.config.server.port}/${trimStart(url, '/')}`
297
+ if (!url.startsWith('http') && guessHost) url = `http://${this.config.server.host}:${this.config.server.port}/${trimStart(url, '/')}`
298
298
  return url
299
299
  }
300
300
 
@@ -5,7 +5,7 @@ async function buildHomesMenu (req) {
5
5
  for (const ns of this.app.bajo.pluginNames) {
6
6
  let home = get(this, `app.${ns}.config.waibuMpa.home`)
7
7
  const homeHandler = get(this, `app.${ns}.config.waibuMpa.homeHandler`)
8
- if (homeHandler) home = await callHandler(homeHandler)
8
+ if (homeHandler) home = await callHandler(this.app[ns], homeHandler)
9
9
  if (!home) continue
10
10
  const item = { href: home, ns, title: get(this, `app.${ns}.config.waibu.title`, this.app[ns].title) }
11
11
  if (!find(routes, { href: home })) routes.push(item)
@@ -15,13 +15,14 @@ async function buildHomesMenu (req) {
15
15
 
16
16
  async function buildPagesMenu (req) {
17
17
  const { find, orderBy, merge, isString } = this.lib._
18
- const { callHandler } = this.app.bajo
18
+ const { callHandler, runHook } = this.app.bajo
19
19
  const all = [{ icon: 'house', href: '/', level: 1 }]
20
20
  for (const ns of this.app.bajo.pluginNames) {
21
21
  const items = []
22
22
  let pages = this.app[ns].getConfig('waibuMpa.menuHandler', { defValue: [] })
23
- if (isString(pages)) pages = await callHandler(pages, req)
23
+ if (isString(pages)) pages = await callHandler(this.app[ns], pages, req)
24
24
  if (pages.length === 0) continue
25
+ await runHook(`${this.name}.${ns}:afterBuildPagesMenu`, pages, req)
25
26
  for (const page of pages) {
26
27
  const existing = find(all, { title: page.title })
27
28
  page.level = page.level ?? 1000
@@ -11,7 +11,7 @@ async function handleForward (ctx) {
11
11
  }
12
12
  }
13
13
 
14
- const base = `http://${this.config.server.address}:${this.config.server.port}`
14
+ const base = `http://${this.config.server.host}:${this.config.server.port}`
15
15
  const options = defaultsDeep({ base }, this.config.forwardOpts)
16
16
  await ctx.register(replyFrom, options)
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {