Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ alwaysApply: false
Default to using Bun instead of Node.js.

- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
- Use `bun test` instead of `jest` or `vitest`
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
Expand Down
67 changes: 55 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,48 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5

postgres-kysely:
image: postgres:17-alpine
env:
POSTGRES_USER: keypal
POSTGRES_PASSWORD: keypal_dev
POSTGRES_DB: keypal_kysely
ports:
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

postgres-drizzle:
image: postgres:17-alpine
env:
POSTGRES_USER: keypal
POSTGRES_PASSWORD: keypal_dev
POSTGRES_DB: keypal_drizzle
ports:
- 5434:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

postgres-prisma:
image: postgres:17-alpine
env:
POSTGRES_USER: keypal
POSTGRES_PASSWORD: keypal_dev
POSTGRES_DB: keypal_prisma
ports:
- 5435:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
Expand All @@ -48,32 +90,33 @@ jobs:
- name: Install dependencies
run: bun install

- name: Create Drizzle database
run: |
docker run --rm --network host -e PGPASSWORD=keypal_dev postgres:17-alpine psql -h localhost -U keypal -d postgres -c "CREATE DATABASE keypal_drizzle;" || true

- name: Run tests
run: bun run test --exclude '**/prisma.test.ts'
run: bun run test --exclude '**/prisma.test.ts' --exclude '**/kysely.test.ts' --exclude '**/drizzle.test.ts'

- name: Run Redis tests
run: bun run test:redis
env:
REDIS_URL: redis://localhost:6379

- name: Run Kysely tests
run: bun run test:kysely
env:
DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5433/keypal_kysely

- name: Run Drizzle tests
run: bun run test:drizzle
env:
DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5434/keypal_drizzle

- name: Push Prisma schema
run: bunx prisma db push
env:
DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5432/keypal
DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5435/keypal_prisma

- name: Run Prisma tests
run: bun run test:prisma
env:
DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5432/keypal

- name: Run Drizzle tests
run: bun run test:drizzle
env:
DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5432/keypal_drizzle
DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5435/keypal_prisma

build:
name: Build
Expand Down
4 changes: 2 additions & 2 deletions FEATURE_SUGGESTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ await keys.revokeBulk(['key_1', 'key_2', 'key_3'])
### 5. Key Templates
```typescript
// Define reusable templates
keys.defineTemplate('readonly', {
const template = keys.defineTemplate('readonly', {
scopes: ['read'],
expiresIn: '30d',
})

const { key } = await keys.createFromTemplate('readonly', {
const { key } = await keys.createFromTemplate(template, {
ownerId: 'user_123',
})
```
Expand Down
3 changes: 3 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default defineBuildConfig({
"src/storage/redis.ts",
"src/storage/drizzle.ts",
"src/storage/prisma.ts",
"src/storage/kysely.ts",
"src/drizzle/schema.ts",
],
declaration: true,
Expand All @@ -36,5 +37,7 @@ export default defineBuildConfig({
"drizzle-orm/node-postgres",
"@prisma/client",
"ioredis",
"kysely",
"pg",
],
});
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,57 @@ services:
timeout: 3s
retries: 5

postgres-kysely:
image: postgres:18-alpine
container_name: keypal-postgres-kysely
ports:
- "5433:5432"
environment:
POSTGRES_USER: keypal
POSTGRES_PASSWORD: keypal_dev
POSTGRES_DB: keypal_kysely
volumes:
- postgres-kysely-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U keypal"]
interval: 5s
timeout: 3s
retries: 5

postgres-drizzle:
image: postgres:18-alpine
container_name: keypal-postgres-drizzle
ports:
- "5434:5432"
environment:
POSTGRES_USER: keypal
POSTGRES_PASSWORD: keypal_dev
POSTGRES_DB: keypal_drizzle
volumes:
- postgres-drizzle-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U keypal"]
interval: 5s
timeout: 3s
retries: 5

postgres-prisma:
image: postgres:18-alpine
container_name: keypal-postgres-prisma
ports:
- "5435:5432"
environment:
POSTGRES_USER: keypal
POSTGRES_PASSWORD: keypal_dev
POSTGRES_DB: keypal_prisma
volumes:
- postgres-prisma-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U keypal"]
interval: 5s
timeout: 3s
retries: 5

redis:
image: redis:7-alpine
container_name: keypal-redis
Expand All @@ -32,4 +83,7 @@ services:

volumes:
postgres-data:
postgres-kysely-data:
postgres-drizzle-data:
postgres-prisma-data:
redis-data:
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"types": "./dist/storage/prisma.d.ts",
"require": "./dist/storage/prisma.cjs",
"import": "./dist/storage/prisma.mjs"
},
"./kysely": {
"types": "./dist/storage/kysely.d.ts",
"require": "./dist/storage/kysely.cjs",
"import": "./dist/storage/kysely.mjs"
}
},
"repository": {
Expand Down Expand Up @@ -66,6 +71,7 @@
"test:redis": "vitest run src/storage/redis.test.ts",
"test:drizzle": "vitest run src/storage/drizzle.test.ts",
"test:prisma": "vitest run src/storage/prisma.test.ts",
"test:kysely": "vitest run src/storage/kysely.test.ts",
"prisma:generate": "prisma generate",
"bench": "bun run benchmark.ts",
"example:hono": "bun run examples/hono-api.ts",
Expand Down Expand Up @@ -103,7 +109,8 @@
"ioredis": "^5.8.2",
"drizzle-orm": "^0.44.6",
"drizzle-kit": "^0.31.0",
"@prisma/client": "^6.18.0"
"@prisma/client": "^6.18.0",
"kysely": "^0.28.8"
},
"dependencies": {
"convex": "^1.28.0",
Expand Down
2 changes: 1 addition & 1 deletion src/storage/drizzle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("DrizzleStore", () => {
pool = new Pool({
connectionString:
process.env.DATABASE_URL ||
"postgresql://keypal:keypal_dev@localhost:5432/keypal",
"postgresql://keypal:keypal_dev@localhost:5434/keypal_drizzle",
});

try {
Expand Down
Loading