Giter VIP home page Giter VIP logo

d1-northwind's Introduction

D1 Northwind Demo

This repo has the code for https://northwind.d1sql.com/

What we use

Get the demo running

Requirements:

Clone this repo

git clone https://github.com/cloudflare/d1-northwind

Note that this repository uses npm workspaces to manage dependencies. You can run either Worker's npm commands from the root of the repo by adding either -w frontend or -w worker to your npm command.

Install packages

npm install

Creating the database

npm run db:new

Get the output database id and add it to worker/wrangler.toml

[[d1_databases]]
binding = "DB"
database_name = "northwind"
database_id = "..."

Importing the database

npm run db:init
npm run db:load

React application

Northwind is a React/Remix/Tailwind CSS application. The source code is in the app folder folder.

To build a new version run:

npm run build -w frontend

To run the dev server, run:

npm run dev -w frontend

Worker backend

Worker serves the Database API endpoints. The source code is in the worker folder.

Local development

Wrangler D1 has support for local development:

npm run local:init -w worker
npm run local:load -w worker
npm run dev -w worker

This will start the Worker at http://127.0.0.1:8787 with the database loaded with data. At this point you can start the frontend in a separate terminal window:

npm run dev -w frontend

Wrangler will persist a local SQLite compatible sql file which you can access to with other clients:

sqlite3 worker/.wrangler/state/v3/d1/*/db.sqlite
.tables

Deploying

Deploy to production when you're done.

npm run deploy -w worker
npm run deploy -w frontend

d1-northwind's People

Contributors

dependabot[bot] avatar dotjs avatar elithrar avatar geelen avatar rozenmd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

d1-northwind's Issues

Issue with loading the demo

It seems that there is an error the in the deployment of the worker. When I try to open the demo I get this error:

CleanShot 2023-08-26 at 18 49 28@2x

A few notes:

  • The demo works fine locally
  • Current implementation can be improved by checking whether the server response exists or not, before checking its length (see below). However, that won't fix the core issue.
const Suppliers = () => {
  // some component logic
  return (
    <>
-      {suppliers.length ? (
+      {suppliers?.length ? (
        <div className="card has-table">

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.