Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ POWERSYNC_PUBLIC_KEY=
POWERSYNC_URL=
PORT=
JWT_ISSUER=
# Either 'mongodb', 'mysql' or 'postgres'. This defaults to Postgres
# Either 'mongodb', 'mysql', 'mssql' or 'postgres'. This defaults to Postgres
DATABASE_TYPE=
DATABASE_URI=
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM node:20

ENV DATABASE_URI=
# Either 'mongodb' or 'postgres'. This defaults to Postgres
# Either 'mongodb', 'postgres', 'mssql' or 'mysql'. This defaults to Postgres
ENV DATABASE_TYPE=
ENV POWERSYNC_PRIVATE_KEY=
ENV POWERSYNC_PUBLIC_KEY=
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

This 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 PostgreSQL or MongoDB database.
This 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 PostgreSQL, MySQL, MSSQL or MongoDB database.

The endpoints are as follows:

Expand Down Expand Up @@ -34,11 +34,16 @@ The endpoints are as follows:

[mysql2](https://www.npmjs.com/package/mysql2) is used to interact with the MySQL database when a client performs requests to the `/api/data` endpoint.

[node-mssql](https://www.npmjs.com/package/mssql) is used to connect to a MSSQL database to perform operations from the `/api/data` endpoint.

[jose](https://github.com/panva/jose) is used to sign the JWT which PowerSync uses for authorization.

## Requirements

This app needs a Postgres instance that's hosted. For a free version for testing/demo purposes, visit [Supabase](https://supabase.com/).
Based on configuration, this app needs a Postgres, Mongo, MSSQL or MySQL instance. Easiest is probably to use docker containers for these databases.
Hosted free versions that can also be used:
1. Postgres: For a free version for testing/demo purposes, visit [Supabase](https://supabase.com/).
2. MSSQL: For a free version of Azure SQL for testing/demo purposes, visit [Azure SQL](https://learn.microsoft.com/en-us/azure/azure-sql/database/free-offer?view=azuresql).

## Running the app

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
"express": "^4.18.2",
"jose": "^5.3.0",
"mongodb": "^6.9.0",
"mssql": "^12.1.0",
"mysql2": "^3.11.3",
"pg": "^8.11.3",
"winston": "^3.11.0"
},
"devDependencies": {
"@types/node": "^22.7.5",
"@types/mssql": "^9.1.8",
"prettier": "^3.2.4",
"typescript": "^5.6.2"
}
Expand Down
Loading