Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huksley/interactive-rest
Initiates a long-running HTTP request and receives progress events before response are received.
https://github.com/huksley/interactive-rest
javascript pusher vercel
Last synced: about 2 months ago
JSON representation
Initiates a long-running HTTP request and receives progress events before response are received.
- Host: GitHub
- URL: https://github.com/huksley/interactive-rest
- Owner: huksley
- Created: 2022-10-08T09:16:12.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-05T13:58:56.000Z (almost 2 years ago)
- Last Synced: 2024-04-15T06:42:43.453Z (8 months ago)
- Topics: javascript, pusher, vercel
- Language: JavaScript
- Homepage: https://interactive-rest.vercel.app
- Size: 393 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Interactive REST
## Abstract
Usually APIs return a response quickly, but sometimes processing can take a long time, and would be nice to have a visual feedback on what is happenning at the server-side.
## Experiment
This example project uses Pusher API to provide update during long running API operation.
1. Generate request ID
2. Subscribe to Pusher events for this ID
3. Invoke API endpoint
4. API endpoint generates events and sends them over [Pusher](https://pusher.com/), AWS SNS, Replicache or other event message API
5. Client side receives events
6. Show progress (messages or progress bar)
7. Receive response**NOTE: This is a Proof of concept. See server-side code in [src/api/ping.js](src/api/ping.js) and client side code in [src/pages/EventBus.jsx](src/pages/EventBus.jsx)**
### Features
- More responsive UI
- Serverless compatible### Drawbacks
- Increased complexity
- Adds another service into the mix
- No guaranteed delivery (some events might not be delivered, delivered out of order, delivered twice, just your normal async problems)### Queue implementation
The same approach can be implemented in a queue processing (for a longer/more expensive task). Task can notify all subscribes about it current progress by sending events with a correlation ID.
### Todo
- FIXME: Processing uploaded file?