Skip to content

Commit

Permalink
Merge pull request #1 from decentraland/feat/allow-sync-server-responses
Browse files Browse the repository at this point in the history
feat: allow any response from the server, async or not
  • Loading branch information
nicosantangelo committed Jul 24, 2019
2 parents 2740548 + 1288105 commit a70b6fe
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 a70b6fe

Please sign in to comment.