Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neondatabase-labs/cloudflare-drizzle-neon
Example API using Cloudflare Workers, Drizzle ORM and Neon
https://github.com/neondatabase-labs/cloudflare-drizzle-neon
cloudflare-workers drizzle drizzle-orm honojs neon postgres postgresql
Last synced: 7 days ago
JSON representation
Example API using Cloudflare Workers, Drizzle ORM and Neon
- Host: GitHub
- URL: https://github.com/neondatabase-labs/cloudflare-drizzle-neon
- Owner: neondatabase-labs
- Created: 2023-05-29T23:46:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-05T16:27:57.000Z (5 months ago)
- Last Synced: 2024-10-25T10:36:46.872Z (14 days ago)
- Topics: cloudflare-workers, drizzle, drizzle-orm, honojs, neon, postgres, postgresql
- Language: TypeScript
- Homepage: https://neon.tech/blog/api-cf-drizzle-neon
- Size: 234 KB
- Stars: 41
- Watchers: 10
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Serverless API using Cloudflare, Drizzle ORM and Neon
This is a simple API of a serverless API using Cloudflare Workers, Drizzle ORM and Neon. It returns a list of products from a Neon database. If you would like to learn how to build this project from scratch, check out the tutorial: https://neon.tech/blog/api-cf-drizzle-neon
## Set up locally
You will need the following:
- A [Cloudflare account](https://dash.cloudflare.com) and the wrangler CLI installed
- A [Neon account](https://console.neon.tech) and a project1. Clone the repository
```
git clone https://github.com/neondatabase/cloudflare-drizzle-neon.git
cd neon-cloudflare-drizzle
npm install
```
2. Copy the `.dev.vars` file by running the following command:```bash
cp .dev.vars.example .dev.vars
```3. Update the `.dev.vars` file with your Neon connection string.
4. Run the following command to apply the existing database migrations located in the `/drizzle` directory:
```bash
npm run migrate
```
5. In the Neon console, run the following query in the Neon's SQL editor:```sql
INSERT INTO products (name, price, description) VALUES
('Product A', 10.99, 'This is the description for Product A.'),
('Product B', 5.99, 'This is the description for Product B.'),
('Product C', 15.99, 'This is the description for Product C.'),
('Product D', 8.99, 'This is the description for Product D.'),
('Product E', 20.99, 'This is the description for Product E.');
```6. Run the following command to start the server:
```bash
npm run dev
```7. Open the browser at `http://localhost:8787` to see the list of products.