{"id":26125963,"url":"https://github.com/powersync-ja/powersync-railway-nodejs-template","last_synced_at":"2025-06-27T06:34:57.108Z","repository":{"id":212732360,"uuid":"732132238","full_name":"powersync-ja/powersync-railway-nodejs-template","owner":"powersync-ja","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-19T22:26:30.000Z","size":127,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T12:49:45.403Z","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":"apache-2.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}},"created_at":"2023-12-15T18:14:16.000Z","updated_at":"2023-12-19T19:24:30.000Z","dependencies_parsed_at":"2023-12-20T08:51:49.200Z","dependency_job_id":null,"html_url":"https://github.com/powersync-ja/powersync-railway-nodejs-template","commit_stats":null,"previous_names":["kobiebotha/railway-poc","kobiebotha/powersync-railway-nodejs-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/powersync-ja/powersync-railway-nodejs-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-railway-nodejs-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-railway-nodejs-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-railway-nodejs-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-railway-nodejs-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/powersync-ja","download_url":"https://codeload.github.com/powersync-ja/powersync-railway-nodejs-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powersync-ja%2Fpowersync-railway-nodejs-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262208720,"owners_count":23275460,"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:26.536Z","updated_at":"2025-06-27T06:34:57.089Z","avatar_url":"https://github.com/powersync-ja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PowerSync + Node.js + Railway Backend\n\n## Overview\nThis repo contains a starter Node.js server application which has HTTP endpoints to authorize a [PowerSync](https://www.powersync.com/) enabled application to sync data between a SQLite client and a Postgres database. This repo is intended for use as a starter template on [Railway](https://railway.app/).\n\n[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/RfZi6y?referralCode=2vw_V9)\n\nFor an overview of PowerSync, see [here](https://docs.powersync.com/overview/powersync-overview).\n\nOnce you have deployed this template on Railway, you'll need to:\n\n- Implement endpoints to accept client writes\n- Implement an endpoint that generates a JWT for clients to use\n- Implement a JWKS endpoint, used by PowerSync to authenticate JWTs\n\n# Accepting Client Writes\n\nThe relevant endpoints are:\n\n1. PUT `/api/data`\n\n   - PowerSync uses this endpoint to sync upsert events that occurred on the client application.\n\n2. PATCH `/api/data`\n\n   - PowerSync uses this endpoint to sync update events that occurred on the client application.\n\n3. DELETE `/api/data`\n\n    - PowerSync uses this endpoint to sync delete events that occurred on the client application.\n\n# Generating Client JWT\n\nSee our [docs](https://docs.powersync.com/usage/installation/authentication-setup/custom) for additional details.\n\n1. GET `/api/auth/token`\n   -  PowerSync uses this endpoint to retrieve an JWT token that is generated by the server and is used to authenticate requests.\n\n# JWKS endpoint\n   \n1. GET `api/auth/keys` \n   - PowerSync uses this endpoint to retrieve the JWKS to validate the token provided in the response above.  \n\n## Packages Used\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\n## Setup\n\n1. Clone the repository and `nvm use \u0026\u0026 yarn install`\n\n2. Generate a new public/private key pair by running the following command:\n```shell\nyarn keys\n```\nThis will output two new keys in the terminal window. Set these as environment variables on the Railway app:\n```shell\nPOWERSYNC_JWT_PUBLICKEY\nPOWERSYNC_JWT_PRIVATEKEY\n```\n## Local Development\n1. Create a new `.env` file in the root project directory and add the variables as defined in the `.env` file:\n```shell\ncp .env.template .env\n```\n2. Run the following to start the application\n```shell\nyarn start\n```\nThis will start the app on `http://127.0.0.1:PORT`, where PORT is what you specify in your `.env` file.\n\n3. Test if the app is working by opening `http://127.0.0.1:PORT/api/auth/keys/` in the browser\n\n4. You should get a JSON object as the response to that request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowersync-ja%2Fpowersync-railway-nodejs-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowersync-ja%2Fpowersync-railway-nodejs-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowersync-ja%2Fpowersync-railway-nodejs-template/lists"}