dxfrontier / cds-ts-dispatcher

SAP CAP TypeScript entity handler dispatcher.
11 stars 2 forks source link

[FEATURE] new decorators `@AfterAll`, `@BeforeAll`, `@OnAll` #60

Closed dragolea closed 3 months ago

dragolea commented 3 months ago

Description

Handle all events in one decorator like @AfterAll which will have the CREATE, READ, UPDATE, DELETE, BOUND ACTION, BOUNS FUNCTION

Suggested solution

  @AfterAll()
  private async afterAll(
    @Req() req: Request,
    @Res() res: RequestResponse,
    @Result() result: Book | Book[] | boolean,
  ): Promise<void> {
    if (Array.isArray(result)) {
      // when after `read` event was triggered
      // console.log('READ');
    } else if (typeof result === 'boolean') {
      // when after `delete` event was triggered
      // console.log('DELETE');
    } else {
      // when after `create`, `update` as triggered
      // console.log('CREATE and UPDATE');
    }
  }