waibu-rest-api 1.2.1 → 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/{waibu → extend/waibu}/boot.js +11 -10
- package/index.js +1 -1
- package/lib/route-by-model-builder.js +3 -2
- package/lib/route-by-verb.js +1 -1
- package/package.json +1 -1
- /package/{bajo → extend/bajo}/hook/waibu-rest-api@pre-parsing.js +0 -0
- /package/{bajo → extend/bajo}/hook/waibu@after-init.js +0 -0
- /package/{bajo → extend/bajo}/intl/en-US.json +0 -0
- /package/{bajo → extend/bajo}/intl/id.json +0 -0
- /package/{plugin-method → method}/doc-schema/description.js +0 -0
- /package/{plugin-method → method}/doc-schema/for-find.js +0 -0
- /package/{plugin-method → method}/doc-schema/general.js +0 -0
- /package/{plugin-method → method}/doc-schema/lib.js +0 -0
- /package/{plugin-method → method}/doc-schema/model.js +0 -0
- /package/{plugin-method → method}/doc-schema/params.js +0 -0
- /package/{plugin-method → method}/doc-schema/qs.js +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
|
-
import decorate from '
|
|
3
|
-
import routeByModelBuilder from '
|
|
4
|
-
import routeByVerb from '
|
|
5
|
-
import notFound from '
|
|
6
|
-
import error from '
|
|
7
|
-
import subApp from '
|
|
8
|
-
import handleResponse from '
|
|
2
|
+
import decorate from '../../lib/decorate.js'
|
|
3
|
+
import routeByModelBuilder from '../../lib/route-by-model-builder.js'
|
|
4
|
+
import routeByVerb from '../../lib/route-by-verb.js'
|
|
5
|
+
import notFound from '../../lib/not-found.js'
|
|
6
|
+
import error from '../../lib/error.js'
|
|
7
|
+
import subApp from '../../lib/sub-app.js'
|
|
8
|
+
import handleResponse from '../../lib/handle-response.js'
|
|
9
9
|
|
|
10
10
|
const routeActions = { routeByModelBuilder, routeByVerb }
|
|
11
11
|
|
|
@@ -50,11 +50,12 @@ const boot = {
|
|
|
50
50
|
if (this.config.enablePatch) actions.push('replace')
|
|
51
51
|
const me = this
|
|
52
52
|
|
|
53
|
-
await eachPlugins(async function ({ dir
|
|
53
|
+
await eachPlugins(async function ({ dir }) {
|
|
54
|
+
const { name: ns, alias } = this
|
|
54
55
|
const appPrefix = '/' + (ns === me.app.bajo.mainNs ? '' : getPluginPrefix(ns, 'waibuRestApi'))
|
|
55
56
|
const pattern = [
|
|
56
|
-
`${dir}/${pathPrefix}/**/{${actions.join(',')}}.js`,
|
|
57
|
-
`${dir}/${pathPrefix}/**/model-builder.*`
|
|
57
|
+
`${dir}/extend/${pathPrefix}/**/{${actions.join(',')}}.js`,
|
|
58
|
+
`${dir}/extend/${pathPrefix}/**/model-builder.*`
|
|
58
59
|
]
|
|
59
60
|
const files = await fastGlob(pattern)
|
|
60
61
|
if (files.length === 0) return undefined
|
package/index.js
CHANGED
|
@@ -8,11 +8,12 @@ async function routeByModelBuilder ({ file, ctx, dir, pathPrefix, ns, parent })
|
|
|
8
8
|
const { isSet } = this.lib.aneka
|
|
9
9
|
const { methodMap, getParams } = this.app.waibuDb
|
|
10
10
|
const { getInfo } = this.app.dobo
|
|
11
|
-
const { camelCase, omit, merge, keys, filter } = this.lib._
|
|
11
|
+
const { isFunction, camelCase, omit, merge, keys, filter } = this.lib._
|
|
12
12
|
const builder = await readConfig(file, { ns, ignoreError: true })
|
|
13
13
|
builder.disabled = builder.disabled ?? []
|
|
14
14
|
const { schema } = getInfo(builder.model)
|
|
15
|
-
|
|
15
|
+
let url = path.dirname(file).replace(`${dir}/extend/${pathPrefix}`, '').replaceAll('@', ':')
|
|
16
|
+
if (isFunction(builder.url)) url = await builder.url.call(this)
|
|
16
17
|
const methods = keys(methodMap)
|
|
17
18
|
if (this.config.enablePatch) methods.push('replace')
|
|
18
19
|
const me = this
|
package/lib/route-by-verb.js
CHANGED
|
@@ -7,7 +7,7 @@ async function routeByVerb ({ file, ctx, appCtx, dir, pathPrefix, ns, alias, par
|
|
|
7
7
|
const { methodMap, getParams } = this.app.waibuDb
|
|
8
8
|
const { isFunction, merge } = this.lib._
|
|
9
9
|
const me = this
|
|
10
|
-
const url = path.dirname(file).replace(`${dir}/${pathPrefix}`, '')
|
|
10
|
+
const url = path.dirname(file).replace(`${dir}/extend/${pathPrefix}`, '')
|
|
11
11
|
.replaceAll('@@', '*').replaceAll('@', ':')
|
|
12
12
|
const action = path.basename(file, '.js')
|
|
13
13
|
let method = methodMap[action]
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|