From 467721f775bb0ccfd744943554aa57a4ea645865 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Wed, 30 Mar 2022 15:35:09 -0500 Subject: [PATCH] Include request parameters in input(...) sources; bump version --- package.json | 2 +- src/http/lifecycle/Request.ts | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index a41fbec..6a5c29a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@extollo/lib", - "version": "0.9.5", + "version": "0.9.6", "description": "The framework library that lifts up your code.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/http/lifecycle/Request.ts b/src/http/lifecycle/Request.ts index 351372e..4afb702 100644 --- a/src/http/lifecycle/Request.ts +++ b/src/http/lifecycle/Request.ts @@ -7,6 +7,7 @@ import * as url from 'url' import {Response} from './Response' import * as Negotiator from 'negotiator' import {HTTPError} from '../HTTPError' +import {ActivatedRoute} from '../routing/ActivatedRoute' /** * Enumeration of different HTTP verbs. @@ -177,20 +178,25 @@ export class Request extends ScopedContainer implements DataContainer { * @param key */ public input(key?: string): unknown { - if ( !key ) { - return { - ...this.parsedInput, - ...this.query, - ...this.uploadedFiles, + let sources = { + ...this.parsedInput, + ...this.query, + ...this.uploadedFiles, + } + + if ( this.hasKey(ActivatedRoute) ) { + sources = { + ...sources, + ...this.make>(ActivatedRoute).params, } } - if ( key in this.parsedInput ) { - return this.parsedInput[key] + if ( !key ) { + return sources } - if ( key in this.query ) { - return this.query[key] + if ( key in sources ) { + return sources[key] } }