Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
546f7f4fc7 | |||
8536060ce4 | |||
e57c332d82 | |||
df87c6c75e |
8
package-lock.json
generated
8
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apiglobal/typedrequest",
|
||||
"version": "1.0.40",
|
||||
"version": "1.0.42",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -2359,9 +2359,9 @@
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.0.23",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-14.0.23.tgz",
|
||||
"integrity": "sha512-Z4U8yDAl5TFkmYsZdFPdjeMa57NOvnaf1tljHzhouaPEp7LCj2JKkejpI1ODviIAQuW4CcQmxkQ77rnLsOOoKw=="
|
||||
"version": "14.0.26",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-14.0.26.tgz",
|
||||
"integrity": "sha512-W+fpe5s91FBGE0pEa0lnqGLL4USgpLgs4nokw16SrBBco/gQxuua7KnArSEOd5iaMqbbSHV10vUDkJYJJqpXKA=="
|
||||
},
|
||||
"@types/parcel-bundler": {
|
||||
"version": "1.12.1",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apiglobal/typedrequest",
|
||||
"version": "1.0.40",
|
||||
"version": "1.0.42",
|
||||
"private": false,
|
||||
"description": "make typed requests towards apis",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -18,7 +18,7 @@
|
||||
"@gitzone/tstest": "^1.0.43",
|
||||
"@pushrocks/smartexpress": "^3.0.73",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.0.23",
|
||||
"@types/node": "^14.0.26",
|
||||
"tslint": "^6.1.2",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
|
@ -33,12 +33,11 @@ tap.test('should spawn a server to test with', async () => {
|
||||
});
|
||||
|
||||
tap.test('should define a testHandler', async () => {
|
||||
const testTypedRouter = new typedrequest.TypedRouter();
|
||||
testTypedRouter.addTypedHandler(testTypedHandler);
|
||||
testServer.addRoute(
|
||||
'/testroute',
|
||||
new smartexpress.Handler('POST', async (req, res) => {
|
||||
console.log(req.body);
|
||||
res.json(await testTypedHandler.addResponse(req.body));
|
||||
})
|
||||
new smartexpress.HandlerTypedRouter(testTypedRouter as any)
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -92,7 +92,7 @@ export class TypedRouter {
|
||||
* @param typedRequestArg
|
||||
*/
|
||||
public async routeAndAddResponse(typedRequestArg: plugins.typedRequestInterfaces.ITypedRequest) {
|
||||
if (typedRequestArg.correlation.phase === 'request') {
|
||||
if (!typedRequestArg?.correlation?.phase || typedRequestArg.correlation.phase === 'request') {
|
||||
const typedHandler = this.getTypedHandlerForMethod(typedRequestArg.method);
|
||||
|
||||
if (!typedHandler) {
|
||||
@ -106,7 +106,9 @@ export class TypedRouter {
|
||||
|
||||
typedRequestArg = await typedHandler.addResponse(typedRequestArg);
|
||||
} else if (typedRequestArg.correlation.phase === 'response') {
|
||||
this.fireEventInterestMap.findInterest(typedRequestArg.correlation.id)?.fullfillInterest(typedRequestArg);
|
||||
this.fireEventInterestMap
|
||||
.findInterest(typedRequestArg.correlation.id)
|
||||
?.fullfillInterest(typedRequestArg);
|
||||
}
|
||||
return typedRequestArg;
|
||||
}
|
||||
|
Reference in New Issue
Block a user