node.js: browser image caching with correct headers

I’m developing a web application that manages a large amount of images, stores and resizes them. the request of an image is something like: domain:port/image_id/size The server takes the image_id and if there isn’t yet an image of such size it creates it and stores it on filesystem. So everything is ok and the server […]

Server side includes (SSI) with grunt connect web server

We are using yeoman for our dev process and currently using the “grunt server” command to run the grunt connect web server for local development. Every time we save a file, grunt will run all its tasks and reload the browser. The problem is with Server side includes we use to include the header and […]

express 4 router with external file

I have the following files lib/pub lib/pub/index.js app.js On App.js I have: // app.js var express = require(“express”) , app = express() , router = express.Router() ; … router.use(‘/pub’,require(‘./pub’)); and then on index.js // pub/index.js var express = require(‘express’) , router = express.Router() ; console.log(“file loaded successfully”) module.exports = function(){ router.get(‘/’,function(req,res){ console.log(“got the get request”) […]

Meteor: accounts-ui how – to change config?

I’m new to node and Meteor I’ve set up simple log in flow with Meteor and accounts-ui package, coupled with accounts-facebook, but I’ve entered wrong Facebook OAuth data in the setup pop-up. How can I change the parameters that the package uses for communicating with Facebook (that is, app secret, redirect_uri etc?)

npm install not installing things at /usr/bin

I am trying to install SailsJS with: $ sudo npm install -g sails It works, install everything at /home/brunoluiz/npm/lib/node_modules/sails with the following log: /home/brunoluiz/npm/bin/sails -> /home/brunoluiz/npm/lib/node_modules/sails/bin/sails.js sails@0.9.16 /home/brunoluiz/npm/lib/node_modules/sails ├── connect-flash@0.1.1 ├── pluralize@0.0.5 ├── inflection@1.2.5 ├── grunt-sails-linker@0.9.5 ├── grunt-contrib-clean@0.4.1 ├── node-uuid@1.4.0 ├── async@0.2.9 ├── grunt-contrib-concat@0.3.0 ├── grunt-contrib-copy@0.4.1 ├── grunt-contrib-coffee@0.7.0 ├── ejs-locals@1.0.2 ├── ejs@0.8.4 ├── underscore.string@2.3.0 ├── […]

Using Passport.SocketIO cookie parser error

I am using the following: “dependencies”: { “express”: “^4.0.0”, “socket.io”: “0.9.16”, “mongoose”: “^3.8.8”, “passport”: “^0.2.0”, “passport-local”: “^1.0.0”, “express-session”: “^1.0.3”, “cookie-parser”: “^1.0.1”, “body-parser”: “^1.0.2”, “session-mongoose”: “git://github.com/danpe/session-mongoose.git#master”, “passport.socketio”: “^3.0.1” } Setting my socket.io authorization: io.set(“authorization”, passportSocketIo.authorize({ passport : passport, cookieParser: cookieParser(), key: settings.sessionKey, //the cookie where express (or connect) stores its session id. secret: settings.sessionSecret, //the session […]

Most common distinct values mongodb

How to get the most common distinct values of a key in query results. Consider a collection ‘collectionSample’ { name : ‘a’, value: 10, word : ‘baz’ }, { name : ‘a’, value: 65, word : ‘bar’ }, { name : ‘a’, value: 3, word : ‘foo’ }, { name : ‘b’, value: 110, word […]

node-gyp errors on “Cannot find module”

I’m trying to build Atom. When I run npm install, I get an error: Error: Cannot find module ‘C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js’ I’m on Windows. How can I fix this?

Mongoose – sub document validation not working

I have a Schema that looks like so: var minderSchema = mongoose.Schema({ phones: {type: [{ details: { type: { country_code: { type: String, required: true }, region_code: { type: String, required: true }, number: { type: Number, required: true } }, required: true }, }], required: true}, }) That is… a minder is made up […]

NodeJS run tcp server on multiple ports?

Is it possible to run a tcp server in nodejs on multiple ports? var socketServer = net.createServer(function (socket) { socket.on(‘end’, function () { }); socket.on(‘error’, function (error) { }); return socket; }).listen(8080); Any ideas how the above could also run on port 8888?

Node.js is the Best Javascript runtime in the world.