Comments (7)
OK, so you have thought of everything :-)
I was wandering through the resourcejs
code wondering how to block the response.Maybe I would create a flag on on the req
, maybe I would call that flag noResponse
.
So you can imagine my surprise when I came across this line:
respond: function(req, res, next) {
if (req.noResponse || res.headerSent || res.headersSent) { return next(); }
So I updated my example above to:
router.get '/test4/:key', (req, res, next) ->
req.noResponse = true
resj = req.app.resourcejs
async.waterfall [
(cb)->
req.query.key = req.params.key
resj['/api'].get.call this, req, res, ->
return cb res.resource.status unless res.resource.status is 200
cb null, res.resource.item[0]
(api, cb)->
req.body =
key : api.key
vid : '123'
mac : '123'
resj['/verification'].post.call this, req, res, ->
return cb res.resource.status unless res.resource.status is 201
cb null, res.resource.item
], (err, verification)->
return res.sendStatus err if err?
res.render 'verify', title:'verify', vid:verification.vid
And everything worked beautifully. Wonderful.
So now the question is: Who is going to update the readme
so all this stuff is actually documented?
from resourcejs.
@biofractal hah glad you got things worked out!
If you feel so compelled, you can submit a pr to update the README. Unfortunately I am currently swamped so I cant currently do it myself, but if you dont do it, I'll do it when I catch my breath!
Let me know what you decide.
from resourcejs.
@biofractal I just opened 2 issues to help get the ball moving: #15 and #16
I think these are key components of ResourceJS that are currently undocumented, but allow pretty seamless integration with any codebase. Having these documented throughly could ward against simple issues that arise in the future!
from resourcejs.
I gave both of you access to push to this repo, so whoever does it, the other one can accept the pull request. Thanks for your help.
from resourcejs.
@travist thanks, will do!
from resourcejs.
Added #18 and #17 - I will take those.
from resourcejs.
Do we want to just create one big readme - or should we be splitting this down wiki-style?
from resourcejs.
Related Issues (20)
- can't get example in README.md to work HOT 2
- Is there an admin / documentation html-interface for resourcejs? HOT 1
- Return code 200 and empty array instead of error 500 on GET request for empty collection HOT 1
- Type definitions HOT 1
- Allow passing of options down to `save()` method HOT 1
- Add ability to pass options to Document.save()
- Why does `Resource.respond()` call `next()` at the end HOT 2
- Add documentation for `hooks`
- Should `before` and `before[method]` handlers be merged?
- Allow Population on `get()` request
- Allow complex population
- Document all the fields that can be set on `req` in before handlers
- `get()` passes `search` to before hook
- Can't see the swagger UI
- Unable to use get for all data inside my react state HOT 1
- Bug / Question: Virtual Resources
- The regex doesn't work as well
- Fast JSON patch needs to be updated. HOT 2
- How to add custom Error Handler?
- Support mongoose 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resourcejs.