@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'

const app = new App()

app.use(jwt({ secret: 'very secret string', algorithm: 'HS256' }))
app.get('/', (req, res) => {
  res.send('Data inside the payload: ' + req['user'])
})

app.listen(8080)

Private / Public key

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

const app = new App()

app.use(jwt({ secret: ['PRIVATE KEY HERE', 'PUBLIC KEY HERE'], algorithm: 'RS256' }))
app.get('/', (req, res) => {
  res.send('Data inside the payload: ' + req['user'])
})

app.listen(8080)

License

MIT © BRA1L0R

Install

pnpm i @tinyhttp/jwt

Version

0.1.20

Source

packages/jwt