@tinyhttp/jwt

NPM NPM GitHub Workflow Status Coverage

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.3.1

Source

@tinyhttp/jwt