Skip to content

Commit

Permalink
feat: more specific typings
Browse files Browse the repository at this point in the history
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
#	modified:   package.json
#	modified:   src/server/index.ts
#
# Untracked files:
#	.DS_Store
#	.vscode/decentraland-server.code-workspace
#
  • Loading branch information
nicosantangelo committed Jul 31, 2019
1 parent a83d6a5 commit 5924905
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -5,7 +5,7 @@
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"scripts": {
"docs": "npx jsdoc -c conf.json -r src/**/*",
"docs": "jsdoc -c conf.json -r src/**/*",
"lint": "tslint -p src/tsconfig.json",
"lint:fix": "tslint -p src/tsconfig.json --fix",
"init": "mkdir -p dist",
Expand Down
7 changes: 5 additions & 2 deletions src/server/index.ts
Expand Up @@ -22,6 +22,9 @@ export function useRollbar(accessToken: string): void {
* @param callback - Actual handler, the return value will be used as response to the client. It will receive (req, res) as parameters
* @return - Wrapper function
*/
export function handleRequest<T = Request, U = Response>(
callback: (req: T, res: U) => any
): RequestHandler
export function handleRequest(
callback: (req: Request, res: Response) => any
): RequestHandler {
Expand All @@ -47,8 +50,8 @@ export function handleRequest(
* @param param - Searched param
* @return - The param value, it throws if it's not present
*/
export function extractFromReq(req: Request, param: string): string {
let value = ''
export function extractFromReq<T = string>(req: Request, param: string): T {
let value

if (req.query[param]) {
value = req.query[param]
Expand Down

0 comments on commit 5924905

Please sign in to comment.