Giter VIP home page Giter VIP logo

Comments (7)

biofractal avatar biofractal commented on July 26, 2024

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.

zackurben avatar zackurben commented on July 26, 2024

@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.

zackurben avatar zackurben commented on July 26, 2024

@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.

travist avatar travist commented on July 26, 2024

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.

zackurben avatar zackurben commented on July 26, 2024

@travist thanks, will do!

from resourcejs.

biofractal avatar biofractal commented on July 26, 2024

Added #18 and #17 - I will take those.

from resourcejs.

biofractal avatar biofractal commented on July 26, 2024

Do we want to just create one big readme - or should we be splitting this down wiki-style?

from resourcejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.