samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.85k stars 95 forks source link

How to do authentication with nestia? #476

Closed Nethrenial closed 1 year ago

Nethrenial commented 1 year ago

How to implement various authentication patterns used in nestjs with nestia? '

Does it support the same kinds of guards we write for passport js with nestjs?If it does, how to pass the Bearer token with auto-generated client SDK of nestia?

samchon commented 1 year ago

1. Using comment tags

https://nestia.io/docs/sdk/sdk/#comment-tags

2. Manual assignment on IConnection.headers

const reply = await api.functional.some.address(connection, ...);
connection.headers ??= {};
connection.headers.Authorization = reply.token;