pwi-plata-type 0.3.13 → 0.3.16
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/libs/routes.ts
CHANGED
|
@@ -86,12 +86,13 @@ export type _Router = Router & PlataRouterExtras
|
|
|
86
86
|
export type PlataRouterBuilder = (r: PlataRouter) => PlataRouter | Promise<PlataRouter>
|
|
87
87
|
|
|
88
88
|
export type PlataRequest = express.Request & {
|
|
89
|
-
user: any,
|
|
89
|
+
user: any,
|
|
90
|
+
extras: any,
|
|
91
|
+
_onResponse: PlataOnResponse[]
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
export type PlataOnResponse = (req: PlataRequest, response?: any, error?: PlataError, nodeError?: any) => Promise<any>
|
|
93
95
|
export interface PlataResponse extends express.Response {
|
|
94
|
-
_onResponse: PlataOnResponse[]
|
|
95
96
|
_oldJson(body?: any): this
|
|
96
97
|
_onResponseEvent(req: PlataRequest, response?: any, error?: PlataError, nodeError?: any): void
|
|
97
98
|
error(error: PlataError, nodeError?: any): this
|
|
@@ -149,19 +150,21 @@ export function PlataRoute(r: PlataRequestHandler): express.RequestHandler {
|
|
|
149
150
|
|
|
150
151
|
const aRes = res as any
|
|
151
152
|
|
|
152
|
-
if (
|
|
153
|
-
|
|
153
|
+
if (aReq._onResponse === undefined) {
|
|
154
|
+
aReq._onResponse = []
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
if (aRes.addOnResponse === undefined) {
|
|
157
|
-
aRes.addOnResponse =
|
|
158
|
+
aRes.addOnResponse = (a) => {
|
|
159
|
+
aReq._onResponse.push(a)
|
|
160
|
+
}
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
if (aRes._oldJson === undefined) {
|
|
161
164
|
aRes._oldJson = aRes.json
|
|
162
165
|
|
|
163
166
|
aRes._onResponseEvent = (...a) => {
|
|
164
|
-
|
|
167
|
+
aReq._onResponse.forEach(r => {
|
|
165
168
|
try {
|
|
166
169
|
r(...a)
|
|
167
170
|
} catch (e) {}
|
|
@@ -263,7 +266,7 @@ export async function buildExpressRouter(): Promise<_Router> {
|
|
|
263
266
|
path: httpPath,
|
|
264
267
|
method: prr.method,
|
|
265
268
|
handlers: [],
|
|
266
|
-
swaggerHide: prr.swaggerHide
|
|
269
|
+
swaggerHide: prr.swaggerHide === undefined ? pr.swaggerHide : undefined
|
|
267
270
|
})
|
|
268
271
|
}
|
|
269
272
|
}
|
package/package.json
CHANGED
|
@@ -22,7 +22,8 @@ export async function install({ dirs, projectPackageJson }) {
|
|
|
22
22
|
projectPackageJson.scripts.start = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata`
|
|
23
23
|
projectPackageJson.scripts.build = `npx tsc && ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-build --`
|
|
24
24
|
projectPackageJson.scripts.create = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-create --`
|
|
25
|
-
projectPackageJson.scripts.dev = "npx nodemon -e '.js,.mjs,.json,.ts' --exec
|
|
25
|
+
projectPackageJson.scripts.dev = "npx nodemon -e '.js,.mjs,.json,.ts' --exec npm run debug"
|
|
26
|
+
projectPackageJson.scripts.debug = `node --inspect -r ts-node/register ./node_modules/${projectPackageJson.plata_name}/bin/plata`
|
|
26
27
|
projectPackageJson.scripts['swagger:gen'] = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-swagger-gen`
|
|
27
28
|
projectPackageJson.scripts['plata:reload'] = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-reload.ts`
|
|
28
29
|
projectPackageJson.main = undefined
|