What’s difference with express-session and cookie-session?

Basically, express-session is more abstract, it supports different session stores (like files, DB, cache and whatnot). And cookie-session is a simple / lightweight cookie-based (cookie is the only storage engine supported: all the session info is stored on the client, in a cookie) session implementation. This kind of sessions is probably most famous for its … Read more

What is a good session store for a single-host Node.js production app?

Spent the day looking into this. Here are the options I’ve discovered. Requests/second are performed via ab -n 100000 -c 1 http://127.0.0.1:9778/ on my local machine. no sessions – fast (438 req/sec) cookieSession: requires no external service, minor speed impact (311 req/sec) – fastest, sessions will expire with the cookie (customised by maxAge) connect-redis: requires … Read more

Is it possible to set a base URL for NodeJS app?

The express router can handle this since 4.0 http://expressjs.com/en/api.html#router http://bulkan-evcimen.com/using_express_router_instead_of_express_namespace.html var express = require(‘express’); var app = express(); var router = express.Router(); // simple logger for this router’s requests // all requests to this router will first hit this middleware router.use(function(req, res, next) { console.log(‘%s %s %s’, req.method, req.url, req.path); next(); }); // this will … Read more

How to get rid of Connect 3.0 deprecation alert?

This is a warning that will go away once Express updates to use Connect 3.0 – as a temporary fix, follow the instructions at the top of https://github.com/senchalabs/connect/wiki/Connect-3.0. Specifically, find this line in your app: app.use(express.bodyParser()); And replace it with the following (this is what bodyParser will be in 3.0): app.use(express.json()); app.use(express.urlencoded());

Express js form data

You should install body-parser through npm-install. Now it comes as a separate middleware. After that add following line in your app.js var bodyParser = require(‘body-parser’); app.use(bodyParser.json()); app.use(bodyParser.urlencoded()); // in latest body-parser use like below. app.use(bodyParser.urlencoded({ extended: true })); It parses the post request as an object. You will get your variables in req.body. In your … Read more

nodejs connect cannot find static

The connect package has made some changes in the latest 3.x version of their code base, moving the static middleware to it’s own package. You can view the list of packages that have been moved here. So you have two options: Option 1 You can install an older, 2.x version of connect and use that … Read more

Everyauth vs Passport.js?

Chiming in with my two cents, as the developer of Passport. Before developing Passport, I evaluated everyauth and determined that it didn’t meet my requirements. So, I set about implementing a different solution which would. The major points I wanted to address are: Idiomatic Node.js everyauth makes extensive use of promises, instead of Node’s approach … Read more