-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from typestack/next
New major release (0.8.x)
- Loading branch information
Showing
14 changed files
with
291 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import {ParamOptions} from "../decorator-options/ParamOptions"; | ||
import {getMetadataArgsStorage} from "../index"; | ||
|
||
/** | ||
* Injects all request's route parameters to the controller action parameter. | ||
* Must be applied on a controller action parameter. | ||
*/ | ||
export function Params(): Function { | ||
export function Params(options?: ParamOptions): Function { | ||
return function (object: Object, methodName: string, index: number) { | ||
getMetadataArgsStorage().params.push({ | ||
type: "params", | ||
object: object, | ||
method: methodName, | ||
index: index, | ||
parse: false, // it does not make sense for Param to be parsed | ||
required: false, | ||
classTransform: undefined | ||
parse: options ? options.parse : false, | ||
required: options ? options.required : undefined, | ||
classTransform: options ? options.transform : undefined, | ||
explicitType: options ? options.type : undefined, | ||
validate: options ? options.validate : undefined, | ||
}); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import {ParamOptions} from "../decorator-options/ParamOptions"; | ||
import {getMetadataArgsStorage} from "../index"; | ||
|
||
/** | ||
* Injects all request's query parameters to the controller action parameter. | ||
* Must be applied on a controller action parameter. | ||
*/ | ||
export function QueryParams(): Function { | ||
export function QueryParams(options?: ParamOptions): Function { | ||
return function (object: Object, methodName: string, index: number) { | ||
getMetadataArgsStorage().params.push({ | ||
type: "queries", | ||
object: object, | ||
method: methodName, | ||
index: index, | ||
parse: false, | ||
required: false | ||
name: "", | ||
parse: options ? options.parse : false, | ||
required: options ? options.required : undefined, | ||
classTransform: options ? options.transform : undefined, | ||
explicitType: options ? options.type : undefined, | ||
validate: options ? options.validate : undefined, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ParamOptions } from "../decorator-options/ParamOptions"; | ||
import { getMetadataArgsStorage } from "../index"; | ||
|
||
/** | ||
* Injects a Session object property to the controller action parameter. | ||
* Must be applied on a controller action parameter. | ||
*/ | ||
export function SessionParam(propertyName: string, options?: ParamOptions): ParameterDecorator { | ||
return function (object: Object, methodName: string, index: number) { | ||
getMetadataArgsStorage().params.push({ | ||
type: "session-param", | ||
object: object, | ||
method: methodName, | ||
index: index, | ||
name: propertyName, | ||
parse: false, // it makes no sense for Session object to be parsed as json | ||
required: options && options.required !== undefined ? options.required : false, | ||
classTransform: options && options.transform, | ||
validate: options && options.validate !== undefined ? options.validate : false, | ||
}); | ||
}; | ||
} |
Oops, something went wrong.