waibu 1.2.12 → 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 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.BajoPlugin {
18
+ return class Waibu extends this.lib.Plugin {
19
19
  constructor () {
20
20
  super(pkgName, me.app)
21
21
  this.alias = 'w'
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 ({ config, file, ns, alias }) {
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 ({ ns }) {
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
- m.path = this.app.waibu.routePath(m.path)
14
- m.methods = santizeMethods(m.methods)
15
- items.push(m)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "1.2.12",
3
+ "version": "2.0.0",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes