-
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.
- Loading branch information
Showing
7 changed files
with
181 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
head: | ||
- - link | ||
- rel: canonical | ||
href: https://signaldb.js.org/replication/appwrite/ | ||
--- | ||
# Integrate SignalDB with [Appwrite](https://appwrite.io/) | ||
|
||
Appwrite is a secure end-to-end backend server for Web, Mobile, and Flutter developers that is packaged as a set of Docker containers for easy deployment. Appwrite provides a set of REST APIs that allow you to build complex applications and workflows. It also offers a cloud service that you can use to host your Appwrite server. | ||
|
||
SignalDB can be integrated with Appwrite to provide real-time data synchronization across multiple clients. | ||
|
||
Checkout our example to learn how to integrate SignalDB with Appwrite: [SignalDB Appwrite Example](/examples/appwrite/) | ||
|
||
If you have any questions or need help, feel free to ask a question on [Github](https://github.com/maxnowack/signaldb/discussions). |
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,15 @@ | ||
--- | ||
head: | ||
- - link | ||
- rel: canonical | ||
href: https://signaldb.js.org/replication/firebase/ | ||
--- | ||
# Integrate SignalDB with [Firebase](https://firebase.google.com/) | ||
|
||
Firebase is a platform developed by Google for creating mobile and web applications. It provides a variety of services, including a real-time database, cloud storage, authentication, and more. | ||
|
||
SignalDB can be integrated with Firebase to provide real-time data synchronization across multiple clients. | ||
|
||
Checkout our example to learn how to integrate SignalDB with Firebase: [SignalDB Firebase Example](/examples/firebase/) | ||
|
||
If you have any questions or need help, feel free to ask a question on [Github](https://github.com/maxnowack/signaldb/discussions). |
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,75 @@ | ||
--- | ||
head: | ||
- - link | ||
- rel: canonical | ||
href: https://signaldb.js.org/replication/http/ | ||
--- | ||
# Replicating Data with External HTTP REST API in SignalDB | ||
|
||
If you've familiarized yourself with the [Replication Overview](/replication/), you're likely already acquainted with the process of achieving replication using an external HTTP REST API. | ||
|
||
This page is dedicated to guiding you through the utilization of your existing HTTP REST API for data replication with SignalDB. | ||
|
||
## Setup | ||
|
||
To initiate data replication with an external HTTP REST API, you'll first need to create your Collection utilizing the specialized `ReplicatedCollection` class. In the following example, we'll illustrate this process using a straightforward todo list collection. | ||
|
||
```js | ||
const Todos = new ReplicatedCollection({ | ||
pull: async () => { | ||
// We're fetching the todos from the API in the pull method | ||
// and returning the items to be added to the collection | ||
const items = await fetch('https://api.example.com/todos').then(res => res.json()) | ||
return { items } | ||
}, | ||
push: async (changes) => { | ||
// In the push method, we're sending the changes to the API | ||
// We have to differentiate between added, modified, and removed items | ||
await Promise.all([ | ||
// For added items, we're sending a POST request with the item data in the body | ||
...changes.added.map(async (item) => { | ||
await fetch('https://api.example.com/todos', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
id: item.id, | ||
text: item.text, | ||
completed: item.completed, | ||
}), | ||
}) | ||
}), | ||
|
||
// For modified items, we're sending a PATCH request with the item data in the body | ||
// You maybe have to change it to PUT or something else depending on your API | ||
...changes.modified.map(async (item) => { | ||
await fetch(`https://api.example.com/todos/${item.id}`, { | ||
method: 'PATCH', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
text: item.text, | ||
completed: item.completed, | ||
}), | ||
}) | ||
}), | ||
|
||
// For removed items, we're sending a DELETE request | ||
...changes.removed.map(async (item) => { | ||
await fetch(`https://api.example.com/todos/${item.id}`, { | ||
method: 'DELETE', | ||
}) | ||
}), | ||
]) | ||
}, | ||
}) | ||
``` | ||
That's it! You've successfully set up a collection that replicates data with an external HTTP REST API. | ||
|
||
## Next Steps | ||
|
||
Make sure you take a look at our [HTTP Replication Example](/examples/replication-http/) to see a full example of how you can replicate data with an external HTTP REST API. | ||
|
||
If you have any questions or need help, feel free to ask a question on [Github](https://github.com/maxnowack/signaldb/discussions). |
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,14 @@ | ||
--- | ||
head: | ||
- - link | ||
- rel: canonical | ||
href: https://signaldb.js.org/replication/other/ | ||
--- | ||
# Other Replication Options | ||
|
||
If the provided replication options don't suit your needs, you can always implement your own replication logic. SignalDB provides a flexible API that allows you to create custom replication logic with any external data source. You can take a look at the [`ReplicatedCollection` class](https://github.com/maxnowack/signaldb/blob/main/packages/signaldb/src/ReplicatedCollection.ts) to get started. | ||
|
||
Another option is to use the [RxDB Persistence Adapter](/data-persistence/rxdb/), which allows you to use the replication functionality of RxDB together with SignalDB. The replication protocol of RxDB is currently more powerful and maybe fills your needs better. | ||
|
||
For guidance on implementing custom replication logic or integrating SignalDB with your backend, don't hesitate to engage with the community on [Github](https://github.com/maxnowack/signaldb/discussions). | ||
``` |
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,13 @@ | ||
--- | ||
head: | ||
- - link | ||
- rel: canonical | ||
href: https://signaldb.js.org/replication/supabase/ | ||
--- | ||
# Integrate SignalDB with [Supabase](https://supabase.io/) | ||
|
||
Supabase is an open-source Firebase alternative that provides a variety of services, including a real-time database, authentication, and more. SignalDB can be integrated with Supabase to provide real-time data synchronization across multiple clients. | ||
|
||
Checkout our example to learn how to integrate SignalDB with Supabase: [SignalDB Supabase Example](/examples/supabase/) | ||
|
||
If you have any questions or need help, feel free to ask a question on [Github](https://github.com/maxnowack/signaldb/discussions). |