https://github.com/ericclemmons/redux-server
Redux-powered server & middleware for predictably handling requests with immutable responses.
https://github.com/ericclemmons/redux-server
Last synced: 5 months ago
JSON representation
Redux-powered server & middleware for predictably handling requests with immutable responses.
- Host: GitHub
- URL: https://github.com/ericclemmons/redux-server
- Owner: ericclemmons
- License: mit
- Created: 2016-01-20T04:46:07.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-20T05:02:04.000Z (over 10 years ago)
- Last Synced: 2026-01-14T06:12:31.536Z (5 months ago)
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redux-server
> Redux-powered server & middleware for predictably handling requests with immutable responses.
## Why?
Over the past several years, I've bounced between Express, Koa, Hapi, and finally back to Express for my server needs.
With React, React Router, & GraphQL, the server has become increasingly simple.
Unfortunately, the majority of middleware rely on clobbering objects & references (e.g. monkey-patching `res.send`, mutating objects `req.session`, adding to `res.locals`, etc.) just to send a request.
In fact, if a middleware calls `res.send`, other middleware have to hijack it with their own version just to intercept the response!
This approach allows for the `response` object to be handled dynamically, allowing for several scenarios:
- Universal API calls on both the client & server.
- Responding to various errors differently.
- Short-circuiting the dispatch with a redirect.
- Rendering the payload as JSON, HTML, or even Markdown.
- Hooking into the payload for tracking events.
- Simpler `response` object for logging & debugging.
- - -
_More to come_