tokenHandler
function tokenHandler(payload: Object, secret: string, args: Object = {})
Asynchronously generates a JSON Web Token (JWT).
See the official jsonwebtoken package documentation for more details:
Returns: Promise<string>
- A promise that resolves to the generated JWT.
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
payload | Object | The payload to encode in the token. | ||
secret | string | The secret key used to sign the token. | ||
args | Object | ✔️ | Additional options for the JWT (e.g., expiresIn). |
See:
const token = await tokenHandler({ userId: 123 }, "mySecret", { expiresIn: "1h" });