waibu-rest-api 1.1.3 → 1.1.4
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/handle-response/xml.js +1 -1
- package/lib/route-by-model-builder.js +1 -1
- package/lib/route-by-verb.js +1 -1
- package/lib/serve-route.js +1 -1
- package/package.json +1 -1
- package/plugin/factory.js +5 -5
- package/plugin/method/doc-schema/general.js +1 -1
- package/plugin/method/doc-schema/lib.js +1 -1
- package/plugin/method/doc-schema/model.js +2 -2
- package/plugin/method/doc-schema/params.js +1 -1
- package/plugin/method/doc-schema/qs.js +1 -1
- package/waibu/boot.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
async function xml (req, reply, payload) {
|
|
2
2
|
const { importPkg } = this.app.bajo
|
|
3
3
|
const { XMLBuilder } = await importPkg('bajoExtra:fast-xml-parser', { returnDefault: false })
|
|
4
|
-
const { get, set, isPlainObject, isArray } = this.
|
|
4
|
+
const { get, set, isPlainObject, isArray } = this.lib._
|
|
5
5
|
const { wrapper, valueAsAttributes, declaration } = this.config.format.xml.response
|
|
6
6
|
|
|
7
7
|
reply.type('application/xml; charset=utf-8')
|
|
@@ -7,7 +7,7 @@ async function routeByModelBuilder ({ file, ctx, dir, pathPrefix, ns, parent })
|
|
|
7
7
|
const { readConfig, parseObject, isSet } = this.app.bajo
|
|
8
8
|
const { methodMap, getParams } = this.app.waibuDb
|
|
9
9
|
const { getInfo } = this.app.dobo
|
|
10
|
-
const { camelCase, omit, merge, keys } = this.
|
|
10
|
+
const { camelCase, omit, merge, keys } = this.lib._
|
|
11
11
|
const builder = await readConfig(file, { ns, ignoreError: true })
|
|
12
12
|
const { schema } = getInfo(builder.model)
|
|
13
13
|
const url = path.dirname(file).replace(`${dir}/${pathPrefix}`, '').replaceAll('@', ':')
|
package/lib/route-by-verb.js
CHANGED
|
@@ -4,7 +4,7 @@ import serveRoute from './serve-route.js'
|
|
|
4
4
|
async function routeByVerb ({ file, ctx, appCtx, dir, pathPrefix, ns, alias, parent }) {
|
|
5
5
|
const { importModule, parseObject, isSet } = this.app.bajo
|
|
6
6
|
const { methodMap, getParams } = this.app.waibuDb
|
|
7
|
-
const { isFunction, merge } = this.
|
|
7
|
+
const { isFunction, merge } = this.lib._
|
|
8
8
|
const me = this
|
|
9
9
|
const url = path.dirname(file).replace(`${dir}/${pathPrefix}`, '')
|
|
10
10
|
.replaceAll('@@', '*').replaceAll('@', ':')
|
package/lib/serve-route.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
async function serveRoute ({ mod, ns, parent }) {
|
|
2
2
|
const { defaultsDeep, importModule } = this.app.bajo
|
|
3
3
|
const { getPluginPrefix } = this.app.waibu
|
|
4
|
-
const { pick } = this.
|
|
4
|
+
const { pick } = this.lib._
|
|
5
5
|
const mergeRouteHooks = await importModule('waibu:/lib/webapp-scope/merge-route-hooks.js')
|
|
6
6
|
const cfgWdb = this.app.waibuDb.config
|
|
7
7
|
mod.config = mod.config ?? {}
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -60,13 +60,13 @@ async function factory (pkgName) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
init = async () => {
|
|
63
|
-
const { uniq } = this.
|
|
63
|
+
const { uniq } = this.lib._
|
|
64
64
|
this.config.format.supported.push('json')
|
|
65
65
|
this.config.format.supported = uniq(this.config.format.supported)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
routePath = (name, { defFormat = '.json' } = {}) => {
|
|
69
|
-
const { get, trimStart } = this.
|
|
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 : '')
|
|
@@ -76,7 +76,7 @@ async function factory (pkgName) {
|
|
|
76
76
|
|
|
77
77
|
transformResult = ({ data, req, reply, options = {} }) => {
|
|
78
78
|
const reformat = ({ data, req, reply, options = {} }) => {
|
|
79
|
-
const { forOwn, get } = this.
|
|
79
|
+
const { forOwn, get } = this.lib._
|
|
80
80
|
const newData = {}
|
|
81
81
|
forOwn(data, (v, k) => {
|
|
82
82
|
let key = get(this.config, `responseKey.${k}`, k)
|
|
@@ -88,7 +88,7 @@ async function factory (pkgName) {
|
|
|
88
88
|
|
|
89
89
|
const returnError = ({ data, req, reply, options = {} }) => {
|
|
90
90
|
const { pascalCase } = this.app.bajo
|
|
91
|
-
const { last, map, kebabCase, upperFirst, keys, each, get, isEmpty } = this.
|
|
91
|
+
const { last, map, kebabCase, upperFirst, keys, each, get, isEmpty } = this.lib._
|
|
92
92
|
const cfg = this.config
|
|
93
93
|
const cfgWdb = this.app.waibuDb.config
|
|
94
94
|
const errNames = kebabCase(data.constructor.name).split('-')
|
|
@@ -110,7 +110,7 @@ async function factory (pkgName) {
|
|
|
110
110
|
|
|
111
111
|
const returnSuccess = ({ data, req, reply, options = {} }) => {
|
|
112
112
|
const { pascalCase } = this.app.bajo
|
|
113
|
-
const { each, keys, omit, get } = this.
|
|
113
|
+
const { each, keys, omit, get } = this.lib._
|
|
114
114
|
const cfg = this.config
|
|
115
115
|
const cfgWdb = this.app.waibuDb.config
|
|
116
116
|
if (reply) {
|
|
@@ -45,7 +45,7 @@ async function buildPropsReqs ({ schema, method, options = {} }) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async function buildResponse ({ ctx, schema, method, options }) {
|
|
48
|
-
const { merge, cloneDeep } = this.
|
|
48
|
+
const { merge, cloneDeep } = this.lib._
|
|
49
49
|
const { transformResult } = this.app.waibuRestApi
|
|
50
50
|
const cfgWdb = this.app.waibuDb.config
|
|
51
51
|
const { properties } = await buildPropsReqs.call(this, { schema, method, options })
|
|
@@ -113,7 +113,7 @@ async function buildResponse ({ ctx, schema, method, options }) {
|
|
|
113
113
|
async function docSchemaModel ({ model, method, ctx, options = {} }) {
|
|
114
114
|
const { getInfo } = this.app.dobo
|
|
115
115
|
const { schema } = getInfo(model)
|
|
116
|
-
const { omit } = this.
|
|
116
|
+
const { omit } = this.lib._
|
|
117
117
|
const out = {
|
|
118
118
|
description: options.description ?? this.docSchemaDescription(method),
|
|
119
119
|
tags: [this.alias.toUpperCase(), ...(options.alias ?? [])]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
async function buildParams (ctx, paramName, ...args) {
|
|
2
|
-
const { each, isEmpty, keys, last, isBoolean } = this.
|
|
2
|
+
const { each, isEmpty, keys, last, isBoolean } = this.lib._
|
|
3
3
|
const cfgWeb = this.app.waibu.config
|
|
4
4
|
let transform = false
|
|
5
5
|
if (isBoolean(last(args))) {
|
package/waibu/boot.js
CHANGED
|
@@ -17,7 +17,7 @@ const boot = {
|
|
|
17
17
|
level: 10,
|
|
18
18
|
handler: async function (ctx, prefix) {
|
|
19
19
|
const { importPkg, eachPlugins, importModule, runHook } = this.app.bajo
|
|
20
|
-
const { fastGlob } = this.
|
|
20
|
+
const { fastGlob } = this.lib
|
|
21
21
|
const { getPluginPrefix } = this.app.waibu
|
|
22
22
|
const [bodyParser, accepts] = await importPkg('waibu:@fastify/formbody', 'waibu:@fastify/accepts')
|
|
23
23
|
const routeHook = await importModule('waibu:/lib/webapp-scope/route-hook.js')
|