-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from powersync-ja/mongo-demo
[Feature] MongoDB Demo
- Loading branch information
Showing
17 changed files
with
127 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ==================== MongoDB credentials ================================ | ||
PS_DATA_SOURCE_URI=mongodb://mongo:27017/powersync_demo_backend | ||
|
||
# ==================== Demo config ========================================= | ||
DEMO_BACKEND_PORT=6060 | ||
DEMO_BACKEND_DATABASE_TYPE=mongodb | ||
DEMO_BACKEND_DATABASE_URI=${PS_DATA_SOURCE_URI} | ||
# The front-end demo application is accessible at this port on the host machine | ||
DEMO_CLIENT_PORT=3033 | ||
PS_JWKS_URL=http://demo-backend:${DEMO_BACKEND_PORT}/api/auth/keys | ||
|
||
# These can be generated by following the instructions in the `key-generator` folder | ||
# A temporary key will be used if these are not specified | ||
DEMO_JWKS_PUBLIC_KEY= | ||
DEMO_JWKS_PRIVATE_KEY= | ||
|
||
# ==================== PowerSync variables ==================== | ||
# The PowerSync API is accessible via this port | ||
PS_PORT=8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# JavaScript PowerSync + MongoDB Self Hosted Demo | ||
|
||
This demo contains a NodeJS + MongoDB backend and React frontend which are linked to a self hosted PowerSync instance. | ||
|
||
Backend code can be found [here](https://github.com/powersync-ja/powersync-nodejs-backend-todolist-demo) | ||
|
||
## Running | ||
|
||
The `.env` file contains default configuration for the services. Reference this to connect to any services locally. | ||
|
||
This demo can be started by running the following in this demo directory | ||
|
||
```bash | ||
docker compose up | ||
``` | ||
|
||
or in the root directory run | ||
|
||
```bash | ||
docker compose -f demos/nodejs-mongodb/docker-compose.yaml up | ||
``` | ||
|
||
The frontend can be accessed at `http://localhost:3033` in a browser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yaml-language-server: $schema=../schema/schema.json | ||
telemetry: | ||
# Opt out of reporting anonymized usage metrics to PowerSync telemetry service | ||
disable_telemetry_sharing: false | ||
|
||
# Settings for source database replication | ||
replication: | ||
connections: | ||
- type: mongodb | ||
uri: !env PS_DATA_SOURCE_URI | ||
|
||
# Connection settings for sync bucket storage | ||
storage: | ||
type: mongodb | ||
uri: !env PS_MONGO_URI | ||
|
||
# The port which the PowerSync API server will listen on | ||
port: !env PS_PORT | ||
|
||
# Specify sync rules | ||
sync_rules: | ||
path: sync_rules.yaml | ||
|
||
# Client (application end user) authentication settings | ||
client_auth: | ||
# JWKS URIs can be specified here | ||
jwks_uri: !env PS_JWKS_URL | ||
|
||
audience: ["powersync-dev", "powersync"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# See Documentation for more information: | ||
# https://docs.powersync.com/usage/sync-rules | ||
# Note that changes to this file are not watched. | ||
# The service needs to be restarted for changes to take effect. | ||
bucket_definitions: | ||
global: | ||
data: | ||
# mongodb uses _id as the primary key. * excludes _ fields. | ||
- select _id as id, * from lists | ||
- select _id as id, * from todos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Include syntax requires Docker compose > 2.20.3 | ||
# https://docs.docker.com/compose/release-notes/#2203 | ||
include: | ||
# Creates a MongoDB replica set. This is used for internal and data storage | ||
- path: ../../services/mongo.yaml | ||
|
||
# Demo NodeJS backend server and front-end web client | ||
- path: ../nodejs/ps-nodejs-demo.yaml | ||
|
||
services: | ||
# Extend PowerSync with Mongo and Postgres healthchecks | ||
powersync: | ||
extends: | ||
file: ../../services/powersync.yaml | ||
service: powersync | ||
depends_on: | ||
mongo-rs-init: | ||
condition: service_completed_successfully | ||
# MongoDB support is available via this image version | ||
image: journeyapps/powersync-service:0.0.0-dev-20240919151547 | ||
volumes: | ||
- ./config:/config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters