waibu 1.2.0 → 1.2.2

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.
Files changed (2) hide show
  1. package/index.js +10 -7
  2. package/package.json +1 -1
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
- host: '127.0.0.1',
25
+ host: '0.0.0.0',
26
26
  port: 7771
27
27
  },
28
28
  factory: {
@@ -138,11 +138,13 @@ async function factory (pkgName) {
138
138
  this.instance.close()
139
139
  }
140
140
 
141
- findRoute (route) {
141
+ findRoute = (route) => {
142
142
  const { outmatch } = this.lib
143
143
  const { find } = this.lib._
144
144
  const { breakNsPath } = this.app.bajo
145
- const { ns, subNs = '', path } = breakNsPath(route)
145
+ let { ns, subNs = '', path } = breakNsPath(route)
146
+ const params = path.split('|')
147
+ if (params.length > 1) path = params[0]
146
148
  return find(this.routes, r => {
147
149
  if (r.path.startsWith('*')) return false
148
150
  r.config = r.config ?? {}
@@ -289,8 +291,9 @@ async function factory (pkgName) {
289
291
  return url
290
292
  }
291
293
 
292
- sendMail = async (tpl, { to, cc, bcc, from, subject, data = {}, conn, options = {} }) => {
293
- if (!this.app.masohiMail) return
294
+ sendMail = async (tpl, { to, cc, bcc, from, subject, data = {}, conn, source, options = {} }) => {
295
+ conn = conn ?? 'masohiMail:default'
296
+ if (!this.app.masohi || !this.app.masohiMail) return
294
297
  const { get, isString } = this.lib._
295
298
  const { generateId } = this.app.bajo
296
299
  const { render } = this.app.bajoTemplate
@@ -302,8 +305,8 @@ async function factory (pkgName) {
302
305
  }
303
306
  const message = await render(tpl[0], locals, opts)
304
307
  if (tpl[1]) opts.messageText = await render(tpl[1], locals, opts)
305
- const payload = { type: 'object', data: { to, cc, bcc, from, subject, message, conn, options: opts } }
306
- await this.app.masohi.send({ payload, source: this.name }, false) // mail sent through worker
308
+ const payload = { type: 'object', data: { to, cc, bcc, from, subject, message, options: opts } }
309
+ await this.app.masohi.send({ payload, source: source ?? this.name, conn }) // mail sent through worker
307
310
  }
308
311
 
309
312
  unescapeBlock = (content, start, end, startReplacer, endReplacer) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {