Skip to content

Commit

Permalink
feat: allow any response from the server, async or not
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 feat/allow-sync-server-responses
# Changes to be committed:
#	modified:   src/server/index.ts
#
# Changes not staged for commit:
#	modified:   package-lock.json
#	modified:   package.json
#
# Untracked files:
#	.DS_Store
#	.vscode/decentraland-server.code-workspace
#
  • Loading branch information
nicosantangelo committed Jul 24, 2019
1 parent 2740548 commit 1288105
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/server/index.ts
Expand Up @@ -16,13 +16,14 @@ export function useRollbar(accessToken: string): void {
* Wrapper for the request handler. It creates the appropiate response object and catches errors. For example:
* app.post('/api/path', handleRequest(async (req, res) => {
* const param = extractFromReq(req, 'param')
* await something()
* return 'Success'
* }))
* @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(
callback: (req: Request, res: Response) => Promise<any>
callback: (req: Request, res: Response) => any
): RequestHandler {
return async (req, res) => {
try {
Expand Down

0 comments on commit 1288105

Please sign in to comment.