pwi-plata-type 0.3.12 → 0.3.15
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/cluster.ts
CHANGED
|
@@ -86,7 +86,7 @@ export class PlataClusterManager {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
if (this.Cluster.eventNames().indexOf('message') === -1) {
|
|
89
|
-
this.Cluster.on('message', this._clusterMsgServer)
|
|
89
|
+
this.Cluster.on('message', this._clusterMsgServer(this))
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -179,19 +179,21 @@ export class PlataClusterManager {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
private
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
182
|
+
private _clusterMsgServer(t: PlataClusterManager) {
|
|
183
|
+
return async (_worker: typeCluster.Worker, msg: PlataClusterMsg) => {
|
|
184
|
+
if (msg.name !== '_plata') {
|
|
185
|
+
// TODO :::
|
|
186
|
+
} else {
|
|
187
|
+
switch(msg.data.action) {
|
|
188
|
+
case 'KILL':
|
|
189
|
+
console.log('Solicitado kill do app')
|
|
190
|
+
process.exit(0)
|
|
191
|
+
;
|
|
192
|
+
case 'ECHO':
|
|
193
|
+
t.sendAllWorkers(msg.data.msg)
|
|
194
|
+
return
|
|
195
|
+
;
|
|
196
|
+
}
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
}
|
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) {}
|
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
|