elysia-auth-drizzle
TypeScript icon, indicating that this package has built-in type declarations

1.2.13 • Public • Published

elysia-auth-drizzle

Library who handle authentification (Header/Cookie/QueryParam).

Usage

import { elysiaAuthDrizzlePlugin } from 'elysia-auth-drizzle';

export const app = new Elysia()
  .use(
      elysiaAuthDrizzlePlugin<typeof users.$inferSelect>({
        config: [
          {
            url: '/public',
            method: 'GET',
          },
        ],
        jwtSecret: 'test',
        drizzle: {
          db: db,
          usersSchema: users,
          tokensSchema: tokens,
        },
      }),
    )

Plugin options

name default description
jwtSecret undefined Secret used to sign JWT
drizzle undefined Contain drizzle db + users schema + tokens schemas ({db, userSchemas, tokenSchemas} / Token Schemas is optional if you use verifyAccessTokenOnlyInJWT)
config [] Array who contain url with method allowed in public
cookieSecret undefined (optional) Secret used to sign cookie value
verifyAccessTokenOnlyInJWT false (optional) Check only JWT expiration not token validity in DB
userValidation undefined (optional) (user) => void or Promise<void> / Allow to make more check regarding user (ex: check if user is banned)

Tests

To execute jest tests (all errors, type integrity test)

bun test

Readme

Keywords

none

Package Sidebar

Install

npm i elysia-auth-drizzle

Weekly Downloads

476

Version

1.2.13

License

none

Unpacked Size

106 kB

Total Files

11

Last publish

Collaborators

  • qlaffont