@universal-packages/trpc-authentication
TypeScript icon, indicating that this package has built-in type declarations

1.5.6 • Public • Published

tRPC Authentication

npm version Testing codecov

universal-authentication implementation on top of trpc

Install

npm install @universal-packages/trpc-authentication

Global methods

initialize(options: Object)

Initialize the authentication api configuration for the authentication trpc routers.

import { initialize } from '@universal-packages/trpc-authentication'

await initialize({ secret: 'my-secret' })

Options

initialize takes the same options as Authentication.

Router creators

createAuthenticationRouter(trpc: TRPCInstance)

Create a trpc router with the authentication methods.

import { initTRPC } from '@trpc/server'
import { createAuthenticationRouter, initialize } from '@universal-packages/trpc-authentication'

await initialize({ secret: 'my-secret' })

export const trpc = initTRPC.create()
export const appRouter = trpc.router({
  authentication: createAuthenticationRouter(trpc)
})

createDefaultAuthenticationModuleRouter(trpc: TRPCInstance)

Create a trpc router with the default authentication module methods. You usually want to combine the base router with other modules.

import { initTRPC } from '@trpc/server'
import { createAuthenticationRouter, createDefaultAuthenticationModuleRouter, initialize } from '@universal-packages/trpc-authentication'

export const trpc = initTRPC.create()
export const appRouter = trpc.router({
  authentication: trpc.mergeRouters(createAuthenticationRouter(trpc), createDefaultAuthenticationModuleRouter(trpc))
})

Typescript

This library is developed in TypeScript and shipped fully typed.

Contributing

The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.

License

MIT licensed.

Readme

Keywords

none

Package Sidebar

Install

npm i @universal-packages/trpc-authentication

Weekly Downloads

10

Version

1.5.6

License

MIT

Unpacked Size

41.8 kB

Total Files

36

Last publish

Collaborators

  • omarandstuff