Skip to content

Commit a33386a

Browse files
authored
instructions on handling delta's in a JS service (#48)
1 parent b75b0e0 commit a33386a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,20 @@ When running inside a mu.semte.ch stack, you could mount your sources and connec
196196
- /absolute/path/to/your/sources/:/app/
197197
```
198198
Now open Chromium, and visit [chrome://inspect/](chrome://inspect/). Once the service is launched, a remote target on localhost should pop up.
199+
200+
## Handling Delta's
201+
If you are building a reactive service that should execute certain logic based on changes in the database, you want to hook it up to the [delta-notifier](https://github.com/mu-semtech/delta-notifier/). Some extra steps need to be taken to properly handle delta's, specifically the route handling delta's will need to use a specific bodyParser.
202+
203+
The default bodyParser provided by the template will only accept `application/vnd.api+json` and the delta-notifier is sending `application/json` content. Aside from that the body of a delta message may be very large, often several megabytes. By specifying the bodyParser on the route accepting delta messages you can easily modify it when required.
204+
205+
An example
206+
```js
207+
// app.js
208+
import bodyParser from 'body-parser';
209+
// ...
210+
211+
app.post("/delta-updates", bodyParser.json({limit: '50mb'}), async function(req, res) {
212+
//...
213+
}
214+
```
215+

0 commit comments

Comments
 (0)