Skip to content

Commit

Permalink
Simplify promise await code
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentClair committed Mar 26, 2024
1 parent 4fbf1f8 commit 03efb05
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export class ExpressTemplateService extends TemplateService<ExpressApiHandlerPar
const { methodName, controller, response, validatedArgs, successStatus, next } = params;

try {
const promise = this.buildPromise(methodName, controller, validatedArgs);
const data = await Promise.resolve(promise);
const data = await this.buildPromise(methodName, controller, validatedArgs);
let statusCode = successStatus;
let headers;
if (this.isController(controller)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export class HapiTemplateService extends TemplateService<HapiApiHandlerParameter
const { methodName, controller, h, validatedArgs, successStatus } = params;

try {
const promise = this.buildPromise(methodName, controller, validatedArgs);
const data = await Promise.resolve(promise);
const data = await this.buildPromise(methodName, controller, validatedArgs);
let statusCode = successStatus;
let headers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export class KoaTemplateService extends TemplateService<KoaApiHandlerParameters,
const { methodName, controller, context, validatedArgs, successStatus } = params;

try {
const promise = this.buildPromise(methodName, controller, validatedArgs);
const data = await Promise.resolve(promise);
const data = await this.buildPromise(methodName, controller, validatedArgs);
let statusCode = successStatus;
let headers;

Expand Down

0 comments on commit 03efb05

Please sign in to comment.