-
Notifications
You must be signed in to change notification settings - Fork 402
release: 0.8.x #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release: 0.8.x #315
Changes from all commits
e8cbf59
3e71052
1c97969
6353ca1
4eac44c
1ca0c3c
5aa5087
0087878
4df235e
3c13d39
316d62d
fb18b54
dd4f710
f91d392
d7fe496
d4ce9ca
ccc2e54
bac90a1
673dda9
34ac8ac
0e91408
63d10e4
6d7ce5f
823155c
34cb2e4
6f64c86
888c790
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
}); | ||
}; | ||
} | ||
} |
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, | ||
}); | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,34 +5,17 @@ import { getMetadataArgsStorage } from "../index"; | |
* Injects a Session object to the controller action parameter. | ||
* Must be applied on a controller action parameter. | ||
*/ | ||
export function Session(options?: ParamOptions): ParameterDecorator; | ||
/** | ||
* Injects a Session object to the controller action parameter. | ||
* Must be applied on a controller action parameter. | ||
*/ | ||
export function Session(propertyName: string, options?: ParamOptions): ParameterDecorator; | ||
|
||
export function Session(optionsOrObjectName?: ParamOptions|string, paramOptions?: ParamOptions): ParameterDecorator { | ||
let propertyName: string|undefined; | ||
let options: ParamOptions|undefined; | ||
if (typeof optionsOrObjectName === "string") { | ||
propertyName = optionsOrObjectName; | ||
options = paramOptions || {}; | ||
} else { | ||
options = optionsOrObjectName || {}; | ||
} | ||
|
||
export function Session(options?: ParamOptions): ParameterDecorator { | ||
return function (object: Object, methodName: string, index: number) { | ||
getMetadataArgsStorage().params.push({ | ||
type: "session", | ||
object: object, | ||
method: methodName, | ||
index: index, | ||
name: propertyName, | ||
parse: false, // it makes no sense for Session object to be parsed as json | ||
required: options.required !== undefined ? options.required : true, | ||
classTransform: options.transform, | ||
validate: options.validate !== undefined ? options.validate : false, | ||
required: options && options.required !== undefined ? options.required : true, | ||
classTransform: options && options.transform, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For |
||
validate: options && options.validate !== undefined ? options.validate : false, | ||
}); | ||
}; | ||
} |
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, | ||
}); | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍