@rpcbase/api 0.16.0 → 0.18.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/package.json +1 -1
- package/src/initApi.ts +5 -5
- package/src/loadModel.ts +5 -2
package/package.json
CHANGED
package/src/initApi.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import assert from "assert"
|
|
2
|
+
|
|
2
3
|
import env from "@rpcbase/env"
|
|
3
4
|
import BBPromise from "bluebird"
|
|
4
5
|
import { Application , json } from "express"
|
|
5
|
-
|
|
6
6
|
import { initApiClient } from "@rpcbase/client"
|
|
7
7
|
|
|
8
|
-
import { Api, ApiHandler,
|
|
8
|
+
import { Api, ApiHandler, Middleware } from "./types"
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
// dotenv setup, merge process env with vite process.env file
|
|
@@ -61,9 +61,9 @@ export const initApi = async (app: Application) => {
|
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
const routes = {
|
|
64
|
-
// @ts-
|
|
64
|
+
// @ts-expect-error: Property 'glob' does not exist on type 'ImportMeta'.
|
|
65
65
|
...import.meta.glob("../../auth/src/api/**/handler.ts"),
|
|
66
|
-
// @ts-
|
|
66
|
+
// @ts-expect-error: Property 'glob' does not exist on type 'ImportMeta'.
|
|
67
67
|
...import.meta.glob("@/api/**/handler.ts")
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -73,7 +73,7 @@ export const initApi = async (app: Application) => {
|
|
|
73
73
|
const routeModule = await loadFn()
|
|
74
74
|
routeModule.default(api)
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
const loggedPath = routePath.startsWith("../../")
|
|
77
77
|
? routePath.replace("../../", "@rpcbase/")
|
|
78
78
|
: routePath
|
|
79
79
|
|
package/src/loadModel.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import assert from "assert"
|
|
2
|
+
|
|
2
3
|
import mongoose from "mongoose"
|
|
4
|
+
|
|
3
5
|
import { Ctx } from "./types"
|
|
4
6
|
|
|
7
|
+
|
|
5
8
|
const { APP_NAME, MONGO_PORT } = process.env
|
|
6
9
|
const connections: Record<string, mongoose.Connection> = {}
|
|
7
10
|
|
|
8
|
-
// @ts-
|
|
9
|
-
const modelModules = import.meta.glob(
|
|
11
|
+
// @ts-expect-error: Property 'glob' does not exist on type 'ImportMeta'.
|
|
12
|
+
const modelModules = import.meta.glob("@/models/**/*.ts", { eager: true })
|
|
10
13
|
|
|
11
14
|
const models = Object.entries(modelModules)
|
|
12
15
|
.map(([key, exports]) => {
|