Skip to content

Commit 58159b9

Browse files
authored
feat(kysely): add kysely to starter-kit (#517)
## Summary - Add Kysely integration with Prisma for type-safe raw SQL queries - Add prisma-kysely generator to auto-generate Kysely types from Prisma schema - Add prisma-zod-generator for Zod schema generation - this has been configured with the `minimal` set up so it generates crud and abit more on top - it's also possible to just generate model typings but i thought since most apps will be crud anyway for db, might as well just shove this in - Configure prisma-extension-kysely for seamless Prisma + Kysely usage - Move dependencies to pnpm catalog for centralized version management ## Changes ### New Dependencies - `kysely` - Type-safe SQL query builder - `prisma-extension-kysely` - Prisma extension for Kysely integration - `prisma-kysely` - Generator for Kysely types from Prisma schema - `prisma-zod-generator` - Generator for Zod schemas from Prisma schema ### Configuration - Updated Prisma schema with Kysely and Zod generators - Reorganized generated output to `src/generated/prisma`, `src/generated/kysely`, and `src/generated/zod` - Added `prisma-extension-kysely` and `prisma-kysely` to pnpm catalog ## Test plan - [ ] Run `pnpm prisma generate` to verify all generators work correctly - [ ] Verify Kysely types are generated in `packages/db/src/generated/kysely` - [ ] Verify Zod schemas are generated in `packages/db/src/generated/zod` - [ ] Test Kysely queries with the Prisma extension - [ ] Ensure existing Prisma client usage still works
1 parent 7225059 commit 58159b9

File tree

15 files changed

+1369
-19
lines changed

15 files changed

+1369
-19
lines changed

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"with-env": "dotenv -e ../../.env --",
1515
"test": "vitest",
1616
"storybook": "CI=1 storybook dev -p 6006",
17+
"docker": "docker-compose up",
1718
"build-storybook": "CI=1 storybook build"
1819
},
1920
"dependencies": {

apps/web/src/server/modules/auth/auth.service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,14 @@ export const emailVerifyOtp = async ({
112112
})
113113
}
114114

115+
// NOTE: You can also use `kysely` for your queries
116+
// if you want more fine-grained control.
115117
// Valid token, delete record to prevent reuse
116-
return db.verificationToken.delete({
117-
where: {
118-
identifier: vfnIdentifier,
119-
},
120-
})
118+
return db.$kysely
119+
.deleteFrom('VerificationToken')
120+
.where('identifier', '=', vfnIdentifier)
121+
.returningAll()
122+
.executeTakeFirstOrThrow()
121123
} catch (error) {
122124
// see error code here: https://www.prisma.io/docs/reference/api-reference/error-reference#p2025
123125
if (

apps/web/turbo.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
"dependsOn": ["^build"],
77
"outputs": [".next/**", "!.next/cache/**", "next-env.d.ts"]
88
},
9+
"docker": {
10+
"cache": false
11+
},
912
"dev": {
10-
"persistent": true
13+
"persistent": true,
14+
"dependsOn": ["docker"]
1115
}
1216
}
1317
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- POSTGRES_USER=root
99
- POSTGRES_PASSWORD=root
1010
volumes:
11-
- postgres-volume:/var/lib/postgresql/data
11+
- postgres-volume:/var/lib/postgresql
1212

1313
volumes:
1414
postgres-volume:

0 commit comments

Comments
 (0)