New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

minoro

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minoro

latest
npmnpm
Version
0.13.0
Version published
Maintainers
1
Created
Source

Development

Build

The build is handled by tsdown to bundle the code code into a single file and generate .d.ts files. The sql migration files are bundled as js modules to se can import them in the codebase. The output is placed in the dist folder.

Database

Users can provide either a SQLite database or a PostgreSQL database, meaning that we need to support both.

To achieve this, we use Drizzle ORM to define our schemas (1 schema per database), we then use drizzle-kit (bun run drizzle:generate) to generate the migration files for both databases in .sql format.

Once the migration files are generated, we run them against the databases at runtime useing a custom Kysely migration provider.

The bun run betterauth:generate command generates sql migration files based on the Drizzle schemas for Better Auth. These sql files are immediately transformed into js modules inside the dist directory, so we can use them at runtime. Therefore we import the migrations from the dist directory in development AND in production.

We use Kysely to query the databases and run migrations because it provides a single interface/api to interact with both databases, whereas Drizzle needs to create instances of the database client for each database type.

With drizzle we would need :

import { drizzle as drizzleSqlite } from 'drizzle-orm/bun-sqlite';
import { drizzle as drizzlePg } from 'drizzle-orm/node-postgres';
const db1 = drizzleSqlite();
const db2 = drizzlePg();

which is not ideal when we query our database because we would then need to check what db type we are currently using and use the correct client -> we would need to write each query twice, once for each database type.

With Kysely we can do this:

import { Kysely } from 'kysely';

const db = new Kysely<DatabaseSchema>({
  dialect: new SqliteDialect({
    database: 'path/to/sqlite.db',
  }),
  // or
  dialect: new PostgresDialect({
    pool: new Pool({
      connectionString: 'postgres://user:password@localhost:5432/database',
    }),
  }),
});

This way, we can write our queries once and they will work for both databases.

We still use Drizzle ORM to define our schemas and generate the migration files, as it is a powerful and somewhat easy process that Kysely migration system does not match.

Better Auth

Better auth needs a Database to work, it also needs to generate tables, therefore we need better auth to generate migrations as well. We therefore have the auth.pg.ts and auth.sqlite.ts files that create dummy better auth clients that we then use to generate the Drizzle Schemas for both databases with bun run betterauth:generate.

At runtime, much like the database itself, we pass a Kysely instance to Better Auth and NOT a Drizzle instance.

FAQs

Package last updated on 16 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts