{"id":26125984,"url":"https://github.com/powersync-ja/powersync-nodejs-firebase-backend-todolist-demo","last_synced_at":"2026-03-08T12:37:01.655Z","repository":{"id":208531080,"uuid":"721866591","full_name":"powersync-ja/powersync-nodejs-firebase-backend-todolist-demo","owner":"powersync-ja","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-20T15:42:15.000Z","size":69,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-12T02:39:26.685Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/powersync-ja.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,"publiccode":null,"codemeta":null}},"created_at":"2023-11-21T23:54:08.000Z","updated_at":"2024-12-06T00:54:18.000Z","dependencies_parsed_at":"2024-11-19T05:15:10.231Z","dependency_job_id":null,"html_url":"https://github.com/powersync-ja/powersync-nodejs-firebase-backend-todolist-demo","commit_stats":null,"previous_names":["powersync-ja/powersync-nodejs-firebase-backend","powersync-ja/powersync-nodejs-firebase-backend-todolist-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-nodejs-firebase-backend-todolist-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-nodejs-firebase-backend-todolist-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-nodejs-firebase-backend-todolist-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-nodejs-firebase-backend-todolist-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/powersync-ja","download_url":"https://codeload.github.com/powersync-ja/powersync-nodejs-firebase-backend-todolist-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741198,"owners_count":21154255,"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":[],"created_at":"2025-03-10T17:27:29.338Z","updated_at":"2026-03-08T12:37:01.614Z","avatar_url":"https://github.com/powersync-ja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PowerSync Node.js + Firebase Backend: Demo\n\n## Overview\n\nThis repo contains a demo Node.js server application which has HTTP endpoints to authorize a [PowerSync](https://www.powersync.com/) enabled application to sync data between a client device and a PostgresSQL database. In addition, it has endpoints that allow a PowerSync client to authenticate.\n\nThe endpoints are as follows:\n\n1. GET `/api/auth/token`\n\n   - PowerSync uses this endpoint to retrieve a JWT access token which is used for authentication.\n\n2. GET `/api/auth/keys`\n\n   - PowerSync uses this endpoint to validate the JWT returned from the endpoint above.\n\n3. PUT `/api/data`\n\n   - PowerSync uses this endpoint to sync upsert events that occurred on the client application.\n\n4. PATCH `/api/data`\n\n   - PowerSync uses this endpoint to sync update events that occurred on the client application.\n\n5. DELETE `/api/data`\n\n   - PowerSync uses this endpoint to sync delete events that occurred on the client application.\n\nThe repo also has an integration with [Firebase](https://firebase.google.com/docs/auth) to validate a token provided in the header of the `/api/auth/token` endpoint.\n\n## Packages\n\n- [node-postgres](https://github.com/brianc/node-postgres) is used to interact with the Postgres database when a PowerSync enabled client performs requests to the `/api/data` endpoint.\n- [jose](https://github.com/panva/jose) is used to sign the JWT which PowerSync uses for authorization.\n- [firebase-admin](https://github.com/firebase/firebase-admin-node) is used to connect to Firebase and the `verifyIdToken` function is used to validate the client application request before the app generates a JWT used by PowerSync to sync data.\n\n## Requirements\n\nThis app needs a PostgresSQL instance that's hosted. For a free version for testing/demo purposes, visit [Supabase](https://supabase.com/).\n\n## Running the app\n\n1. Clone the repository\n\n2. Follow the steps outlined in [PowerSync Custom Authentication Example](https://github.com/journeyapps/powersync-jwks-example) → [Generate a key-pair](https://github.com/journeyapps/powersync-jwks-example#1-generate-a-key-pair) to get the key pair you need for this app. This is an easy way to get started with this demo app. You can use your own public/private keys as well.\n\n3. Create a new `.env` file in the root project directory and add the variables as defined in the `.env` file:\n\n```shell\ncp .env.template .env\n```\n\n4. Make sure to place a copy of your Firebase Admin SDK `serviceAccountKey.json` in the root of the project.\n\n   4.1. You can get this file from the firebase console by heading over to your project settings \u003e Service accounts \u003e Firebase Admin SDK \u003e Generate new private key\n\n   4.2. Download the json file and save it in the project root as `serviceAccountKey.json`.\n\n   4.3. Set the `GOOGLE_APPLICATION_CREDENTIALS` to point to the file on your machine e.g\n\n   ```\n   GOOGLE_APPLICATION_CREDENTIALS= /path/to/powersync-nodejs-firebase-backend-todolist-demo/serviceAccountKey.json\n   ```\n\n5. Install dependencies:\n\n**This demo requires [node](https://nodejs.org/en/download/package-manager) to be installed on your system. Alternatively you can install it using [nvm](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating).**\n\n```shell\nyarn\nor\nnpm install\n```\n\n## Start App\n\n1. Run the following to start the application\n\n```shell\nnpm run start\nor\nyarn start\n```\n\nThis will start the app on `http://127.0.0.1:PORT`, where PORT is what you specify in your `.env` file.\n\n2. Test if the app is working by opening `http://127.0.0.1:PORT` in the browser\n\n3. You should get a JSON object that looks like this as the response\n\n```json\n{ \"message\": \"powersync-nodejs-backend-todolist-demo\" }\n```\n\n## Testing the app with PowerSync\n\nThis process is only designed for demo/testing purposes, and is not intended for production use. You won't be using ngrok to host your application and database.\n\n1. Download and install [ngrok](https://ngrok.com/)\n\n2. Run the ngrok command to create a HTTPS tunnel to your local application\n\n```shell\nngrok http \u003cYOUR PORT\u003e\n```\n\nThis should create the tunnel and a new HTTPS URL should be available e.g.\n\n```shell\nngrok by @inconshreveable                                                                                                                  (Ctrl+C to quit)\n\nSession Status                online\nAccount                       Michael Barnes (Plan: Free)\nUpdate                        update available (version 2.3.41, Ctrl-U to update)\nVersion                       2.3.40\nRegion                        United States (us)\nWeb Interface                 http://127.0.0.1:4040\nForwarding                    http://your_id.ngrok-free.app -\u003e http://localhost:8000\nForwarding                    https://your_id.ngrok-free.app -\u003e http://localhost:8000\n\nConnections                   ttl     opn     rt1     rt5     p50     p90\n                              1957    0       0.04    0.03    0.01    89.93\n```\n\n3. Open the [PowerSync Dashboard](https://powersync.journeyapps.com/) and paste the `Forwarding` URL starting with HTTPS into the Client Auth tab of your PowerSync instance e.g.\n\n```\nJWKS URI\nhttps://your_id.ngrok-free.app/api/auth/keys/\n```\n\n\u003e Pay special attention to the URL, it should include the `/api/auth/keys/` path as this is used by the PowerSync server to validate tokens.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowersync-ja%2Fpowersync-nodejs-firebase-backend-todolist-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowersync-ja%2Fpowersync-nodejs-firebase-backend-todolist-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowersync-ja%2Fpowersync-nodejs-firebase-backend-todolist-demo/lists"}