Drop-in serializer support for Express/Connect Node apps.
Create a blackburn middleware function that will override res.render to use the blackburn serializers and renderers. The res.render method takes to arguments:
payload
- either a record, an array of records, or an Error object. Can
also be a Promise which resolves to any of those.options
- any options to pass to the serializer or adapter. Blackburn
doesn't use any of these options out of the box, but this allows you to
pass additional information into any custom adapters or serializers.res.render()
will return a promise which resolves once the response has
been rendered.
import blackburn, { RawAdapter } from 'blackburn';
app.use(blackburn({ adapter: RawAdapter })) app.get('/posts', function(req, res, next) { res.render(Post.find()); });
blackburn middleware function