Skip to content

Commit ba563b0

Browse files
feat: add firebase nodejs demo (#218)
* feat: add firebase nodejs demo * feat: add firebase nodejs demo * chore: update podfile * chore: remove test * fix: lint issue
1 parent 7b41669 commit ba563b0

File tree

156 files changed

+7545
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+7545
-98
lines changed

demos/benchmarks/pubspec.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,18 @@ packages:
159159
dependency: transitive
160160
description:
161161
name: leak_tracker
162-
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
162+
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
163163
url: "https://pub.dev"
164164
source: hosted
165-
version: "10.0.5"
165+
version: "10.0.4"
166166
leak_tracker_flutter_testing:
167167
dependency: transitive
168168
description:
169169
name: leak_tracker_flutter_testing
170-
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
170+
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
171171
url: "https://pub.dev"
172172
source: hosted
173-
version: "3.0.5"
173+
version: "3.0.3"
174174
leak_tracker_testing:
175175
dependency: transitive
176176
description:
@@ -207,18 +207,18 @@ packages:
207207
dependency: transitive
208208
description:
209209
name: material_color_utilities
210-
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
210+
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
211211
url: "https://pub.dev"
212212
source: hosted
213-
version: "0.11.1"
213+
version: "0.8.0"
214214
meta:
215215
dependency: transitive
216216
description:
217217
name: meta
218-
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
218+
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
219219
url: "https://pub.dev"
220220
source: hosted
221-
version: "1.15.0"
221+
version: "1.12.0"
222222
mutex:
223223
dependency: transitive
224224
description:
@@ -425,10 +425,10 @@ packages:
425425
dependency: transitive
426426
description:
427427
name: test_api
428-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
428+
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
429429
url: "https://pub.dev"
430430
source: hosted
431-
version: "0.7.2"
431+
version: "0.7.0"
432432
typed_data:
433433
dependency: transitive
434434
description:
@@ -465,10 +465,10 @@ packages:
465465
dependency: transitive
466466
description:
467467
name: vm_service
468-
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
468+
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
469469
url: "https://pub.dev"
470470
source: hosted
471-
version: "14.2.5"
471+
version: "14.2.1"
472472
web:
473473
dependency: transitive
474474
description:

demos/django-todolist/pubspec.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,18 @@ packages:
172172
dependency: transitive
173173
description:
174174
name: leak_tracker
175-
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
175+
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
176176
url: "https://pub.dev"
177177
source: hosted
178-
version: "10.0.5"
178+
version: "10.0.4"
179179
leak_tracker_flutter_testing:
180180
dependency: transitive
181181
description:
182182
name: leak_tracker_flutter_testing
183-
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
183+
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
184184
url: "https://pub.dev"
185185
source: hosted
186-
version: "3.0.5"
186+
version: "3.0.3"
187187
leak_tracker_testing:
188188
dependency: transitive
189189
description:
@@ -220,18 +220,18 @@ packages:
220220
dependency: transitive
221221
description:
222222
name: material_color_utilities
223-
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
223+
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
224224
url: "https://pub.dev"
225225
source: hosted
226-
version: "0.11.1"
226+
version: "0.8.0"
227227
meta:
228228
dependency: transitive
229229
description:
230230
name: meta
231-
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
231+
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
232232
url: "https://pub.dev"
233233
source: hosted
234-
version: "1.15.0"
234+
version: "1.12.0"
235235
mutex:
236236
dependency: transitive
237237
description:
@@ -494,10 +494,10 @@ packages:
494494
dependency: transitive
495495
description:
496496
name: test_api
497-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
497+
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
498498
url: "https://pub.dev"
499499
source: hosted
500-
version: "0.7.2"
500+
version: "0.7.0"
501501
typed_data:
502502
dependency: transitive
503503
description:
@@ -534,10 +534,10 @@ packages:
534534
dependency: transitive
535535
description:
536536
name: vm_service
537-
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
537+
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
538538
url: "https://pub.dev"
539539
source: hosted
540-
version: "14.2.5"
540+
version: "14.2.1"
541541
web:
542542
dependency: transitive
543543
description:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Symbolication related
36+
app.*.symbols
37+
38+
# Obfuscation related
39+
app.*.map.json
40+
41+
# Android Studio will place build artifacts here
42+
/android/app/debug
43+
/android/app/profile
44+
/android/app/release
45+
46+
# asdf
47+
.tool-versions
48+
49+
# secrets
50+
app_config.dart
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Creative Commons Legal Code
2+
3+
CC0 1.0 Universal
4+
5+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12+
HEREUNDER.
13+
14+
Statement of Purpose
15+
16+
The laws of most jurisdictions throughout the world automatically confer
17+
exclusive Copyright and Related Rights (defined below) upon the creator
18+
and subsequent owner(s) (each and all, an "owner") of an original work of
19+
authorship and/or a database (each, a "Work").
20+
21+
Certain owners wish to permanently relinquish those rights to a Work for
22+
the purpose of contributing to a commons of creative, cultural and
23+
scientific works ("Commons") that the public can reliably and without fear
24+
of later claims of infringement build upon, modify, incorporate in other
25+
works, reuse and redistribute as freely as possible in any form whatsoever
26+
and for any purposes, including without limitation commercial purposes.
27+
These owners may contribute to the Commons to promote the ideal of a free
28+
culture and the further production of creative, cultural and scientific
29+
works, or to gain reputation or greater distribution for their Work in
30+
part through the use and efforts of others.
31+
32+
For these and/or other purposes and motivations, and without any
33+
expectation of additional consideration or compensation, the person
34+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35+
is an owner of Copyright and Related Rights in the Work, voluntarily
36+
elects to apply CC0 to the Work and publicly distribute the Work under its
37+
terms, with knowledge of his or her Copyright and Related Rights in the
38+
Work and the meaning and intended legal effect of CC0 on those rights.
39+
40+
1. Copyright and Related Rights. A Work made available under CC0 may be
41+
protected by copyright and related or neighboring rights ("Copyright and
42+
Related Rights"). Copyright and Related Rights include, but are not
43+
limited to, the following:
44+
45+
i. the right to reproduce, adapt, distribute, perform, display,
46+
communicate, and translate a Work;
47+
ii. moral rights retained by the original author(s) and/or performer(s);
48+
iii. publicity and privacy rights pertaining to a person's image or
49+
likeness depicted in a Work;
50+
iv. rights protecting against unfair competition in regards to a Work,
51+
subject to the limitations in paragraph 4(a), below;
52+
v. rights protecting the extraction, dissemination, use and reuse of data
53+
in a Work;
54+
vi. database rights (such as those arising under Directive 96/9/EC of the
55+
European Parliament and of the Council of 11 March 1996 on the legal
56+
protection of databases, and under any national implementation
57+
thereof, including any amended or successor version of such
58+
directive); and
59+
vii. other similar, equivalent or corresponding rights throughout the
60+
world based on applicable law or treaty, and any national
61+
implementations thereof.
62+
63+
2. Waiver. To the greatest extent permitted by, but not in contravention
64+
of, applicable law, Affirmer hereby overtly, fully, permanently,
65+
irrevocably and unconditionally waives, abandons, and surrenders all of
66+
Affirmer's Copyright and Related Rights and associated claims and causes
67+
of action, whether now known or unknown (including existing as well as
68+
future claims and causes of action), in the Work (i) in all territories
69+
worldwide, (ii) for the maximum duration provided by applicable law or
70+
treaty (including future time extensions), (iii) in any current or future
71+
medium and for any number of copies, and (iv) for any purpose whatsoever,
72+
including without limitation commercial, advertising or promotional
73+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74+
member of the public at large and to the detriment of Affirmer's heirs and
75+
successors, fully intending that such Waiver shall not be subject to
76+
revocation, rescission, cancellation, termination, or any other legal or
77+
equitable action to disrupt the quiet enjoyment of the Work by the public
78+
as contemplated by Affirmer's express Statement of Purpose.
79+
80+
3. Public License Fallback. Should any part of the Waiver for any reason
81+
be judged legally invalid or ineffective under applicable law, then the
82+
Waiver shall be preserved to the maximum extent permitted taking into
83+
account Affirmer's express Statement of Purpose. In addition, to the
84+
extent the Waiver is so judged Affirmer hereby grants to each affected
85+
person a royalty-free, non transferable, non sublicensable, non exclusive,
86+
irrevocable and unconditional license to exercise Affirmer's Copyright and
87+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
88+
maximum duration provided by applicable law or treaty (including future
89+
time extensions), (iii) in any current or future medium and for any number
90+
of copies, and (iv) for any purpose whatsoever, including without
91+
limitation commercial, advertising or promotional purposes (the
92+
"License"). The License shall be deemed effective as of the date CC0 was
93+
applied by Affirmer to the Work. Should any part of the License for any
94+
reason be judged legally invalid or ineffective under applicable law, such
95+
partial invalidity or ineffectiveness shall not invalidate the remainder
96+
of the License, and in such case Affirmer hereby affirms that he or she
97+
will not (i) exercise any of his or her remaining Copyright and Related
98+
Rights in the Work or (ii) assert any associated claims and causes of
99+
action with respect to the Work, in either case contrary to Affirmer's
100+
express Statement of Purpose.
101+
102+
4. Limitations and Disclaimers.
103+
104+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
105+
surrendered, licensed or otherwise affected by this document.
106+
b. Affirmer offers the Work as-is and makes no representations or
107+
warranties of any kind concerning the Work, express, implied,
108+
statutory or otherwise, including without limitation warranties of
109+
title, merchantability, fitness for a particular purpose, non
110+
infringement, or the absence of latent or other defects, accuracy, or
111+
the present or absence of errors, whether or not discoverable, all to
112+
the greatest extent permissible under applicable law.
113+
c. Affirmer disclaims responsibility for clearing rights of other persons
114+
that may apply to the Work or any use thereof, including without
115+
limitation any person's Copyright and Related Rights in the Work.
116+
Further, Affirmer disclaims responsibility for obtaining any necessary
117+
consents, permissions or other rights required for any use of the
118+
Work.
119+
d. Affirmer understands and acknowledges that Creative Commons is not a
120+
party to this document and has no duty or obligation with respect to
121+
this CC0 or use of the Work.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# PowerSync + Node.js + Firebase Auth + Flutter Demo: Todo List App
2+
3+
Demo app demonstrating use of the PowerSync SDK for Flutter together with a custom Node.js backend and using Firebase for user auth on the client.
4+
5+
This demo can run alongside the [powersync-nodejs-firebase-backend-todolist-demo](https://github.com/powersync-ja/powersync-nodejs-firebase-backend-todolist-demo) for testing and demo purposes.
6+
7+
We suggest you first set up the `powersync-nodejs-firebase-backend-todolist-demo` before setting up the client as shown in this repo.
8+
9+
# Running the app
10+
11+
Ensure you have [melos](https://melos.invertase.dev/~melos-latest/getting-started) installed.
12+
13+
1. `cd demos/firebase-nodejs-todolist`
14+
2. `melos prepare`
15+
3. `cp lib/app_config_template.dart lib/app_config.dart`
16+
4. Insert your Supabase and PowerSync project credentials into `lib/app_config.dart` (See instructions below)
17+
5. `flutter run`
18+
19+
# Add your Firebase app
20+
Follow the step found in [this page](https://firebase.google.com/docs/flutter/setup?platform=ios) from the Firebase docs to login to your Firebase account and to initialize the Firebase credentials.
21+
22+
# Set up Supabase project
23+
24+
Create a new Supabase project, and paste and run the contents of [database.sql](./database.sql) in the Supabase SQL editor.
25+
26+
It does the following:
27+
28+
1. Create `lists` and `todos` tables.
29+
2. Create a publication called `powersync` for `lists` and `todos`.
30+
3. Enable row level security (RLS), allowing users to only view and edit their own data.
31+
4. Create a trigger to populate some sample data when a user registers.
32+
33+
We won't be using the Supabase Flutter SDK for this demo, but rather as a hosted PostgresSQL database that the app connects to.
34+
35+
# Set up PowerSync Instance
36+
37+
Create a new PowerSync instance, connecting to the database of the Supabase project.
38+
39+
Then deploy the following sync rules:
40+
41+
```yaml
42+
bucket_definitions:
43+
user_lists:
44+
# Separate bucket per todo list
45+
parameters: select id as list_id from lists where owner_id = request.user_id()
46+
data:
47+
- select * from lists where id = bucket.list_id
48+
- select * from todos where list_id = bucket.list_id
49+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options
29+
30+
analyzer:
31+
exclude:
32+
- lib/firebase.dart # Exclude this as it imports a file that is not checked in

0 commit comments

Comments
 (0)