@hedystia/better-auth-typeorm
TypeScript icon, indicating that this package has built-in type declarations

0.2.0Β β€’Β PublicΒ β€’Β Published

πŸ“¦ @hedystia/better-auth-typeorm

TypeORM adapter for Better Auth - Powerful database integration for your auth system! πŸš€

npm version npm downloads license

🌟 Features

  • πŸ—„οΈ Database Agnostic: Works with all TypeORM-supported databases (MySQL, PostgreSQL, SQLite, etc.)
  • πŸ”„ CRUD Operations: Full support for create, read, update, and delete operations
  • ⚑ Efficient Queries: Built-in pagination, sorting, and filtering support
  • πŸ”’ Secure Operations: Proper transaction handling and error management

πŸš€ Quick Start

  1. Install the package:
npm install @hedystia/better-auth-typeorm typeorm
  1. Create your TypeORM DataSource configuration:
import { DataSource } from "typeorm";
import { entities, migrations } from "@hedystia/better-auth-typeorm";

export const dataSource = new DataSource({
  type: "mysql",
  host: "localhost",
  port: 3306,
  username: "your_username",
  password: "your_password",
  database: "your_database",
  entities: [...entities],
  migrations: [...migrations],
  migrationsRun: true,
});

await dataSource.initialize();
  1. Set up your Better Auth configuration:
import { betterAuth } from "better-auth";
import { typeormAdapter } from "@hedystia/better-auth-typeorm";
import { dataSource } from "./data-source";

export const auth = betterAuth({
  database: typeormAdapter(dataSource),
});

🌟 Why use this adapter?

  • Seamless Integration: Direct mapping between Better Auth entities and TypeORM
  • Flexible Database Support: Use with any TypeORM-supported database
  • Production Ready: Built-in error handling and transaction support
  • Performance Optimized: Efficient query building and data transformation

πŸ“ License

This project is licensed under the MIT License.

πŸ™ Acknowledgements

Package Sidebar

Install

npm i @hedystia/better-auth-typeorm

Weekly Downloads

44

Version

0.2.0

License

MIT

Unpacked Size

19.4 kB

Total Files

4

Last publish

Collaborators

  • zastinian