Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using applyDecorator with nestia #627

Open
loucass003 opened this issue Sep 26, 2023 · 3 comments
Open

Using applyDecorator with nestia #627

loucass003 opened this issue Sep 26, 2023 · 3 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@loucass003
Copy link
Contributor

loucass003 commented Sep 26, 2023

I am trying to use the nestjs applyDecorator method, to group nestjs and nestia decorators together.

it seems like the TypedException is not recognized. is that functionality not supported? is there an alternative ?

import {
  applyDecorators,
  ForbiddenException,
  HttpStatus,
  SetMetadata,
} from '@nestjs/common';
import { Role } from './role.enum';
import { TypedException } from '@nestia/core';

export const ROLE_KEY = 'role';
export const Roles = (role: Role) =>
  applyDecorators(
    SetMetadata(ROLE_KEY, role),
    TypedException<ForbiddenException>(HttpStatus.FORBIDDEN),
  );
  /**
   * Request something
   *
   * @security X-Auth-Token
   */
  @TypedRoute.Post('/request')
  @Roles(Role.ROLE_SUPER_ADMIN)
  public async request() {
    return true;
  }

it would also be nice to have an equivalent to the nestjs @ApiSecurity decorator that does not require a comment.
That way you could add it inside the applyDecorator to not have to specify security in the comment.

@samchon
Copy link
Owner

samchon commented Sep 26, 2023

Not possible due to @nestia/core is based on transformation (AOT compilation).

@samchon samchon self-assigned this Sep 26, 2023
@samchon samchon added the question Further information is requested label Sep 26, 2023
@loucass003
Copy link
Contributor Author

would there be a way to make an aot version of applydecorators? allowing to mix nestjs ans nestia decorators?

@samchon
Copy link
Owner

samchon commented Sep 27, 2023

Have considered the way, but could not get any idea yet. If you have, then suggest me please.

@samchon samchon added the help wanted Extra attention is needed label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants