Code Monkey home page Code Monkey logo

Comments (7)

richardschneider avatar richardschneider commented on September 27, 2024

Do not do app.use(mung); It is not correct.

mung is middleware for middleware. As the readme illustrates you should have your middleware, such as redact call mung.

You have not shown your redact.js, so I can't provide much more help. If you post your code, or even easier just point me to the github repo, I can then provide more details.

Thanks for trying the package.

from express-mung.

0angelic0 avatar 0angelic0 commented on September 27, 2024

OK, I made a github repo here. You can run the app with npm start

The files in focus are app.js and nulljson.js

app.js
line 28 as [1]
line 66 as [2]

nulljson.js
line 12 as [3]

At current state of the repo [2] has been commented and the app is working fine. You can make request at:

  1. http://localhost:3000/api/cinema/0001 < found data
  2. http://localhost:3000/api/cinema/0003 < not found data; response is {} (modified response success)

If I comment [3] which I no longer want to modify the body

  1. http://localhost:3000/api/cinema/0001 < found data
  2. http://localhost:3000/api/cinema/0003 < NOT RESPONDING

Then if I comment [1] and uncomment [2](which [3] is still commented)

  1. http://localhost:3000/api/cinema/0001 < found data
  2. http://localhost:3000/api/cinema/0003 < not found data; response is null, no console output 'nulljson'

The problem is when I comment [3] why the app does not respond?

Thanks

from express-mung.

0angelic0 avatar 0angelic0 commented on September 27, 2024

Another little side note in your usage example

exports = mung.json(redact);

It have to be?

module.exports = mung.json(redact);

from express-mung.

richardschneider avatar richardschneider commented on September 27, 2024

exports and module.exports is allowed by node; see stack overflow

from express-mung.

richardschneider avatar richardschneider commented on September 27, 2024

The pull request gets express-mung and nulljson working.

Basically

  • don't require/use express-mung in app.js
  • do use nulljson in app.js

from express-mung.

richardschneider avatar richardschneider commented on September 27, 2024

24 hours have passed, I assume you are happy with the solution, so I'm closing the issue. But feel free to post a comment and I'll re-open the issue.

Good luck with your app.

from express-mung.

0angelic0 avatar 0angelic0 commented on September 27, 2024

Yes, your solution works perfectly. I comment this just to comfirm that. Sorry for late checking the issue.

Thank you for your help.

from express-mung.

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.