{"id":24390433,"url":"https://github.com/pgedge/pgedge-northwind","last_synced_at":"2025-07-18T10:03:17.378Z","repository":{"id":218618926,"uuid":"741274686","full_name":"pgEdge/pgedge-northwind","owner":"pgEdge","description":"pgEdge Northwind Demo","archived":false,"fork":false,"pushed_at":"2025-03-05T16:04:02.000Z","size":820,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-25T06:33:31.130Z","etag":null,"topics":["cloudflare-pages","cloudflare-workers","nextjs","nodejs","pgedge","postgres","react","typescript"],"latest_commit_sha":null,"homepage":"https://northwind.pgedge.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgEdge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-10T03:53:30.000Z","updated_at":"2025-02-07T19:54:22.000Z","dependencies_parsed_at":"2024-01-23T02:09:22.284Z","dependency_job_id":"127fe06b-aa32-4dc3-9237-d1e90d8207cb","html_url":"https://github.com/pgEdge/pgedge-northwind","commit_stats":null,"previous_names":["pgedge/pgedge-northwind"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgEdge%2Fpgedge-northwind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgEdge%2Fpgedge-northwind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgEdge%2Fpgedge-northwind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgEdge%2Fpgedge-northwind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgEdge","download_url":"https://codeload.github.com/pgEdge/pgedge-northwind/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248366196,"owners_count":21091924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-pages","cloudflare-workers","nextjs","nodejs","pgedge","postgres","react","typescript"],"created_at":"2025-01-19T16:17:34.651Z","updated_at":"2025-04-11T09:15:43.079Z","avatar_url":"https://github.com/pgEdge.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgEdge Northwind Demo\n\nThis repo has the code for https://northwind.pgedge.com/, which a demo of the Northwind dataset, running on Cloudflare Workers® and pgEdge Cloud, a fully-distributed PostgreSQL database, deployable across multiple cloud regions or data centers.\n\nThis code is inspired by the [Cloudflare D1 Northwind Demo](https://github.com/cloudflare/d1-northwind)\n\n## Built With\n\n- [Cloudflare Pages](https://pages.cloudflare.com/) \u0026 [Cloudflare Workers](https://developers.cloudflare.com/workers/) for compute\n- [pgEdge Cloud](https://www.pgedge.com/products/pgedge-cloud) for database\n- [Typescript](https://www.typescriptlang.org/) for stronger types\n- [React](https://react.dev/) for UI Framework\n- [NextJS](https://nextjs.org/) for React Framework\n- [Mantine](https://mantine.dev/) for UI Components\n- [cloudflare-worker-router](https://github.com/tsndr/cloudflare-worker-router) for API routing\n- [node-postgres](https://github.com/brianc/node-postgres) for DB Client Connections\n- [cloudflare-colo-list](https://github.com/Netrvin/cloudflare-colo-list) for Cloudflare Colocation Data\n- [mapbox-gl](https://github.com/mapbox/mapbox-gl-js) for plotting user sessions on a map\n\n## Setup\n\nYou will need a:\n\n* Cloudflare Account\n* pgEdge Cloud Account\n* NodeJS installed with npm + npx\n\n\n### Clone this repo\n\n```\ngit clone https://github.com/pgedge/pgedge-northwind\n```\n\nThis repo contains two components - an `api` Cloudflare worker, and a Cloudflare pages `app`. The `api` worker is setup in a separate npm workspace, which can be accessed using `npm -w api \u003ccommand\u003e`\n\n### Install packages\n\n```\nnpm install\n```\n\n### Setup the pgEdge Database\n\nLogin to pgEdge Cloud, and create a database, and select \"Install Northwind Database\" during setup. \n\nOnce your database is deployed, connect to it using the provided details, and add one additional table:\n\n```\nCREATE TABLE sessions\n  (\n     id         UUID,\n     created_at TIMESTAMP,\n     user_data  JSONB,\n     PRIMARY KEY (id)\n  ) ;\n```\n\nOnce added, click \"Start Replication\" in the UI to ensure all tables are available on all nodes.\n\n### Configure the API Worker\n\nNext, create a `.dev.vars` file under `src/api` with the following contents:\n\n```\nDB=\u003cConnection String from the Nearest Node tab under \"Connect to your database\"\u003e\nNODELIST=\u003cComma separated list of Node Domains, copied from each tab (n1, n2, etc) under \"Connect to your database\"\u003e\n```\n\n### Run the api locally\n\nRun the API worker locally:\n\n```\nnpm run dev -w api\n```\n\nConfirm access to the database is working by navigating to `http://localhost:8787/customers`, which should return some information. \n\n\n### Run the app locally\n\nCreate a `.env.development.local` file in the root of the repository, and provide it with configuration details:\n\n```\nNEXT_PUBLIC_API=http://localhost:8787\nNEXT_PUBLIC_MAPBOX_TOKEN=\u003cOptional Mapbox Token, if you want the map to display\u003e\n```\n\nOnce this is configured, run `npm run dev` from a separate shell, and the UI should be accessible at http://localhost:3000, and use your local api for requests.\n\n### Deploy the api\n\nIf you want to deploy the API into a Cloudflare Worker, you can use the following command to do so via Wrangler:\n\n```\nnpm run deploy -w api\n```\n\nOnce the worker is deployed, you'll need to provide it with the `DB` and `NODELIST` secrets that you configured locally. You can use wrangler to set these:\n\n```\n npx -w api wrangler secret put DB\n npx -w api wrangler secret put NODELIST\n```\n\nProvide the values via direct input. You may need to redeploy the worker afterwards for it to begin utilizing the secrets.\n\nOnce your worker deploy is complete, you should be provided a URL which you can use to deploy the app, or to configure your local app instance to utilize (rather than running the api locally)\n\n### Deploy the app\n\nThe app runs on Cloudflare Pages via next-on-pages, a CLI tool to help build and deploy NextJS applications on Cloudflare.\n\nA [guide](https://github.com/cloudflare/next-on-pages/tree/main/packages/next-on-pages#cloudflarenext-on-pages) is provided for how to deploy an app like this to Cloudflare Pages.\n\nYou'll want to use the \"Local Development\" approach rather than the Git integration. The guide goes into more detail, but this roughly involves:\n\n1. Creating a `.env.production.local` file which contains environment variables required during build. You will want to set `NEXT_PUBLIC_API` to your deployed API worker URL from the previous step. \n2. Building the app via `next-on-pages` via `npx @cloudflare/next-on-pages`\n3. Use wrangler to deploy via `wrangler pages publish .vercel/output/static`. Provide a name for your project and use main for the branch.\n4. Go into the Pages project in Cloudflare, and enable the `nodejs_compat` flag under Settings -\u003e Functions -\u003e Compatibiliy Flags. Populate this value for both Production and Preview\n5. Navigate to the Pages URL that wrangler provided you, and you should see the app.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgedge%2Fpgedge-northwind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgedge%2Fpgedge-northwind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgedge%2Fpgedge-northwind/lists"}