Skip to main content

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.
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
payloadObjectThe payload to encode in the token.
secretstringThe secret key used to sign the token.
argsObject✔️Additional options for the JWT (e.g., expiresIn).

See:

const token = await tokenHandler({ userId: 123 }, "mySecret", { expiresIn: "1h" });