chankruze / cloudflare-drizzle-neon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Set up locally

You will need the following:

  1. Clone the repository
git clone https://github.com/neondatabase/cloudflare-drizzle-neon.git
cd neon-cloudflare-drizzle
npm install
  1. Copy the .dev.vars file by running the following command:
cp .dev.vars.example .dev.vars
  1. Update the .dev.vars file with your Neon connection string.

  2. Run the following command to apply the existing database migrations located in the /drizzle directory:

npm run migrate
  1. In the Neon console, run the following query in the Neon's SQL editor:
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.');
  1. Run the following command to start the server:
npm run dev
  1. Open the browser at http://localhost:8787 to see the list of products.

About


Languages

Language:TypeScript 100.0%