Authorization approaches and design patterns for Node.js applications [closed]

As per your first question, you want some authorization process implementation in NodeJs. I have explored and used number of APIs of NodeJs. I would prefer following APIs for enterprise applications. For Authentication: Passport or Satellizer if developing SPA (front-end) in AngularJS. For Authorization: ACL . Role based security on Methods and REST APIs. I … Read more

How to package & deploy Node.js + express web application?

Deploying Node.js applications is very easy stuff. In maven, there is pom.xml. Related concept in Node.js is package.json. You can state your dependencies on package.json. You can also do environmental setup on package.json. For example, in dev environment you can say that I want to run unit tests. but in production; I want to skip … Read more

How do I ungzip (decompress) a NodeJS request’s module gzip response body?

I couldn’t get request to work either, so ended up using http instead. var http = require(“http”), zlib = require(“zlib”); function getGzipped(url, callback) { // buffer to store the streamed decompression var buffer = []; http.get(url, function(res) { // pipe the response into the gunzip to decompress var gunzip = zlib.createGunzip(); res.pipe(gunzip); gunzip.on(‘data’, function(data) { … Read more

How to create global variables accessible in all views using Express / Node.JS?

After having a chance to study the Express 3 API Reference a bit more I discovered what I was looking for. Specifically the entries for app.locals and then a bit farther down res.locals held the answers I needed. I discovered for myself that the function app.locals takes an object and stores all of its properties … Read more

Node.js request CERT_HAS_EXPIRED

The best way to fix this: Renew the certificate. This can be done for free using Greenlock which issues certificates via Let’s Encrypt™ v2 A less insecure way to fix this: ‘use strict’; var request = require(‘request’); var agentOptions; var agent; agentOptions = { host: ‘www.example.com’ , port: ‘443’ , path: “https://stackoverflow.com/” , rejectUnauthorized: false }; agent … Read more

Multiple optional route parameters in Express?

The expressjs’s guide to routing mentions: Express uses path-to-regexp for matching the route paths; see the path-to-regexp documentation for all the possibilities in defining route paths. Express Route Tester is a handy tool for testing basic Express routes, although it does not support pattern matching. Basically, you can use the ? character to make the … Read more