waibu-rest-api 1.2.2 → 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.
@@ -1,11 +1,11 @@
1
1
  import path from 'path'
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'
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, alias, ns }) {
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
@@ -1,7 +1,7 @@
1
1
  async function factory (pkgName) {
2
2
  const me = this
3
3
 
4
- return class WaibuRestApi extends this.lib.BajoPlugin {
4
+ return class WaibuRestApi extends this.lib.Plugin {
5
5
  constructor () {
6
6
  super(pkgName, me.app)
7
7
  this.alias = 'wra'
@@ -12,7 +12,7 @@ async function routeByModelBuilder ({ file, ctx, dir, pathPrefix, ns, parent })
12
12
  const builder = await readConfig(file, { ns, ignoreError: true })
13
13
  builder.disabled = builder.disabled ?? []
14
14
  const { schema } = getInfo(builder.model)
15
- let url = path.dirname(file).replace(`${dir}/${pathPrefix}`, '').replaceAll('@', ':')
15
+ let url = path.dirname(file).replace(`${dir}/extend/${pathPrefix}`, '').replaceAll('@', ':')
16
16
  if (isFunction(builder.url)) url = await builder.url.call(this)
17
17
  const methods = keys(methodMap)
18
18
  if (this.config.enablePatch) methods.push('replace')
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-rest-api",
3
- "version": "1.2.2",
3
+ "version": "2.0.0",
4
4
  "description": "REST API for Waibu",
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
File without changes