While working in a node.js project, I had an use case where user will have to query based on days and query result will be pdf filtered by the date range. And I have to create a directory of pdf files and return it as a zip file for the user.
As there are many modules related to zip, I tried couple of the active modules but none was meeting my requirements. And some of those modules has different bugs/issues which were open at that time. After different try/error and going through most of the zip modules, I used archiver. And below a sample how it worked.
After cloning the gist make sure you have files to zip and run the script like below:
Happy coding 🙂
I was working with Node.js for building a REST API. For REST API module I was using restify. The restify is a simple and yet powerful node module. One of the use case of the API was, I had to serve static file for specific routing. I went through the docs and tried different things but couldn’t figure yet out at first. After hustling for hours, me and Christian started to go deep into it and figured it out!
So in my case the configuration was something like this
When restify internally resolve the path, it looks for ‘static_content/index.html’.
I have coded a very basic application to show it works, sample application looks like below:
In this sample application the static content (index.html) is in the same root as server.js as why ‘directory’: ‘.’.
Use package.json to install necessary module and start playing 🙂