waibu-rest-api 1.1.7 → 1.1.9
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/lib/route-by-model-builder.js +2 -1
- package/lib/route-by-verb.js +2 -1
- package/lib/serve-route.js +2 -1
- package/package.json +1 -1
- package/plugin/factory.js +5 -4
|
@@ -4,7 +4,8 @@ import serveRoute from './serve-route.js'
|
|
|
4
4
|
async function routeByModelBuilder ({ file, ctx, dir, pathPrefix, ns, parent }) {
|
|
5
5
|
const { getPlugin } = this.app.bajo
|
|
6
6
|
getPlugin('dobo') // ensure dobo is loaded
|
|
7
|
-
const { readConfig, parseObject
|
|
7
|
+
const { readConfig, parseObject } = this.app.bajo
|
|
8
|
+
const { isSet } = this.lib.aneka
|
|
8
9
|
const { methodMap, getParams } = this.app.waibuDb
|
|
9
10
|
const { getInfo } = this.app.dobo
|
|
10
11
|
const { camelCase, omit, merge, keys, filter } = this.lib._
|
package/lib/route-by-verb.js
CHANGED
|
@@ -2,7 +2,8 @@ import path from 'path'
|
|
|
2
2
|
import serveRoute from './serve-route.js'
|
|
3
3
|
|
|
4
4
|
async function routeByVerb ({ file, ctx, appCtx, dir, pathPrefix, ns, alias, parent }) {
|
|
5
|
-
const { importModule, parseObject
|
|
5
|
+
const { importModule, parseObject } = this.app.bajo
|
|
6
|
+
const { isSet } = this.lib.aneka
|
|
6
7
|
const { methodMap, getParams } = this.app.waibuDb
|
|
7
8
|
const { isFunction, merge } = this.lib._
|
|
8
9
|
const me = this
|
package/lib/serve-route.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
async function serveRoute ({ mod, ns, parent }) {
|
|
2
|
-
const { defaultsDeep
|
|
2
|
+
const { defaultsDeep } = this.lib.aneka
|
|
3
|
+
const { importModule } = this.app.bajo
|
|
3
4
|
const { getPluginPrefix } = this.app.waibu
|
|
4
5
|
const { pick } = this.lib._
|
|
5
6
|
const mergeRouteHooks = await importModule('waibu:/lib/webapp-scope/merge-route-hooks.js')
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -65,12 +65,13 @@ async function factory (pkgName) {
|
|
|
65
65
|
this.config.format.supported = uniq(this.config.format.supported)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
routePath = (name, { defFormat = '.json' } = {}) => {
|
|
68
|
+
routePath = (name, { defFormat = '.json', uriEncoded = true } = {}) => {
|
|
69
69
|
const { get, trimStart } = this.lib._
|
|
70
70
|
const { fullPath, ns } = this.app.bajo.breakNsPath(name)
|
|
71
71
|
const prefix = get(this.app[ns], 'config.waibu.prefix', this.app[ns].alias)
|
|
72
72
|
const format = defFormat === false ? '' : (this.config.format.asExt ? defFormat : '')
|
|
73
|
-
|
|
73
|
+
let path = `/${this.config.waibu.prefix}/${prefix}${fullPath}${format}`
|
|
74
|
+
if (uriEncoded) path = path.split('/').map(p => encodeURI(p)).join('/')
|
|
74
75
|
return '/' + trimStart(path, '/')
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -87,7 +88,7 @@ async function factory (pkgName) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
const returnError = ({ data, req, reply, options = {} }) => {
|
|
90
|
-
const { pascalCase } = this.
|
|
91
|
+
const { pascalCase } = this.lib.aneka
|
|
91
92
|
const { last, map, kebabCase, upperFirst, keys, each, get, isEmpty } = this.lib._
|
|
92
93
|
const cfg = this.config
|
|
93
94
|
const cfgWdb = this.app.waibuDb.config
|
|
@@ -109,7 +110,7 @@ async function factory (pkgName) {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
const returnSuccess = ({ data, req, reply, options = {} }) => {
|
|
112
|
-
const { pascalCase } = this.
|
|
113
|
+
const { pascalCase } = this.lib.aneka
|
|
113
114
|
const { each, keys, omit, get } = this.lib._
|
|
114
115
|
const cfg = this.config
|
|
115
116
|
const cfgWdb = this.app.waibuDb.config
|