Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mxvsh/realsync
Execute server functions from client and realtime synchronisation module for modern applications.
https://github.com/mxvsh/realsync
express http nodejs realtime socket-io
Last synced: about 1 month ago
JSON representation
Execute server functions from client and realtime synchronisation module for modern applications.
- Host: GitHub
- URL: https://github.com/mxvsh/realsync
- Owner: mxvsh
- Created: 2021-09-11T08:28:18.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-13T08:39:38.000Z (about 3 years ago)
- Last Synced: 2024-10-04T14:50:00.398Z (about 1 month ago)
- Topics: express, http, nodejs, realtime, socket-io
- Language: TypeScript
- Homepage: https://t.me/xencodes
- Size: 172 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RealSync
> Execute Server Functions from Client side
![banner](https://user-images.githubusercontent.com/31907722/132995756-a13db366-2502-4b30-bec8-2f0ccd1ddfb7.png)
## Usage### Server
Here is a sample code for your Server, you can use Express if you want.
```javascript
const http = require('http')
const app = http.createServer()
const { RealSync } = require('../packages/server/lib')const realsync = new RealSync(app, '*')
realsync.register('profile/setup', async (client) => {
const firstName = await client.run('profile/firstname')
const lastName = await client.run('profile/lastname')return { firstName, lastName }
})app.listen(8080, () => {
console.log('8080')
})
```### Client
```js
import { RealSync } from '@realsync/react'
const realsync = new RealSync('http://localhost:8080')function App() {
useEffect(() => {
// this will register servicesrealsync.register('profile/firstname', () => {
return prompt('Enter first name')
})realsync.register('profile/lastname', () => {
return prompt('Enter last name')
})
}, [])const Start = async () => {
const profile = await realsync.service('profile/setup')
console.log('profile', profile)
}return (
Start
)
}
```