@tinyhttp/jwt

npm (scoped) npm

JWT middleware for HTTP servers.

Install

pnpm i @tinyhttp/jwt

API

import { jwt } from '@tinyhttp/jwt'

Options

jwt(options)

Example

Basic secret

import { App } from '@tinyhttp/app'
import { jwt } from '@tinyhttp/jwt'

new App()
  .use(jwt({ secret: 'secret', algorithm: 'HS256' }))
  .get('/', (req, res) => res.send(`Data inside the payload: ${req['user']}`))
  .listen(8080)

Private / Public key

import { App } from '@tinyhttp/app'
import { jwt } from '@tinyhttp/jwt'

new App()
  .use(jwt({ secret: ['PRIVATE KEY', 'PUBLIC KEY'], algorithm: 'RS256' }))
  .get('/', (req, res) => res.send(`Data inside the payload: ${req['user']}`))
  .listen(8080)

Install

pnpm i @tinyhttp/jwt

Version

1.0.7

Source

packages/jwt