@dilukangelo/api-forge-storage-drizzle
v0.1.2
Published
Drizzle ORM storage adapter for API Forge OAuth
Maintainers
Readme
@dilukangelo/api-forge-storage-drizzle
Drizzle ORM storage adapter for API Forge OAuth.
Installation
npm install @dilukangelo/api-forge-storage-drizzle drizzle-orm
# or
bun add @dilukangelo/api-forge-storage-drizzle drizzle-ormSetup
1. Use the provided schema
Import and use the OAuth schema tables:
// db/schema.ts
import {
oauthClients,
oauthTokens,
oauthAuthCodes,
oauthRateLimits,
oauthConsents,
} from "@dilukangelo/api-forge-storage-drizzle/schema";
// Export alongside your other tables
export * from "@dilukangelo/api-forge-storage-drizzle/schema";
export * from "./your-other-tables";2. Run migrations
npx drizzle-kit generate:pg
npx drizzle-kit push:pg3. Use with API Forge
import { APIForge } from "@dilukangelo/api-forge-core";
import { DrizzleStorageAdapter } from "@dilukangelo/api-forge-storage-drizzle";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
const client = postgres(process.env.DATABASE_URL!);
const db = drizzle(client);
const forge = new APIForge({
storage: {
adapter: new DrizzleStorageAdapter({ db }),
},
auth: {
grants: ["authorization_code", "refresh_token"],
scopes: {
"read:users": "Read user data",
},
},
});Supported Databases
The schema is defined for PostgreSQL. For MySQL or SQLite, you'll need to modify the schema imports:
// For MySQL
import { mysqlTable, varchar, text, boolean, timestamp, int } from "drizzle-orm/mysql-core";
// For SQLite
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";License
MIT
