Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ajzbc/workers-typesafe-db-example
An example Cloudflare Worker API with a typesafe database
https://github.com/ajzbc/workers-typesafe-db-example
cloudflare cloudflare-workers d1 example hono kysely kysely-dialect sql sqlite typesafe typescript
Last synced: 3 months ago
JSON representation
An example Cloudflare Worker API with a typesafe database
- Host: GitHub
- URL: https://github.com/ajzbc/workers-typesafe-db-example
- Owner: ajzbc
- License: mit
- Created: 2023-01-11T09:29:26.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-30T09:19:09.000Z (6 months ago)
- Last Synced: 2024-10-25T10:37:36.713Z (3 months ago)
- Topics: cloudflare, cloudflare-workers, d1, example, hono, kysely, kysely-dialect, sql, sqlite, typesafe, typescript
- Language: TypeScript
- Homepage: https://example.ajzbc.com/post/all
- Size: 23.4 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cloudflare Worker Typesafe DB Example
An example Cloudflare Worker API with a typesafe database
## Stack
- [Cloudflare Workers](https://developers.cloudflare.com/workers/) (serverless)
- [Hono](https://honojs.dev/) (router)
- [Kysely](https://koskimas.github.io/kysely/) (typesafe orm)
- [D1](https://developers.cloudflare.com/d1/) (database)## Setup
Create your database with [Wrangler](https://developers.cloudflare.com/d1/get-started/#3-create-your-database) or through the [Dashboard](https://dash.cloudflare.com)
Set your new `database_name` and `database_id` in `wrangler.toml` [(reference)](https://developers.cloudflare.com/d1/get-started/#4-bind-your-worker-to-your-d1-database)
Run the database migration
```
npm run migrate
```Run locally
```
npm run dev
```## Note
Probably not the best setup, but just what works well for me :)