Socket.IO without http server?

Socket.io, and WebSockets in general, require an http server for the initial upgrade handshake. So even if you don’t supply Socket.io with an http server it will create one for you. The issue is that the second parameter in your io.listen(3000, ‘0.0.0.0’) is ignored by Socket.io. If you need to control which network interface to … Read more

Post request via Chai

The way you have written, I assume that you used chai-http package. The .field() function does not work in chai-http. Another user pointed it out here and opened an issue on github. Here is how you could have written: .set(‘content-type’, ‘application/x-www-form-urlencoded’) .send({myparam: ‘test’}) Here is the full code that successfully passes parameters to the server: … Read more

NodeJS environment variables in Grunt

use the grunt-env plugin: https://npmjs.org/package/grunt-env and set your config: grunt.initConfig({ env : { options : { //Shared Options Hash }, dev : { NODE_ENV : ‘development’, DEST : ‘temp’ } }, ‘another-task’: {} }); in your gruntfile you will probably define some default-task: grunt.registerTask(‘default’, [‘env’, ‘another-task’]); so if you run ‘grunt default’ at first your … Read more

Can Gulp overwrite all src files?

I can think of two solutions: Add an option for base to your gulp.src like so: gulp.src([…files…], {base: ‘./’}).pipe(…)… This will tell gulp to preserve the entire relative path. Then pass ‘./’ into gulp.dest() to overwrite the original files. (Note: this is untested, you should make sure you have a backup in case it doesn’t … Read more

How to fix (node:12388) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated in windows

Node version 12 depracated OutgoingMessage.prototype._headers, which is used in http-server. Issue is listed at: https://github.com/http-party/http-server/issues/537 https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames Using node 12.0.0 I get the same error using http-server. Switching to 10.11.0 removes the error.

req.header vs req.headers in Express

The problem arises because in the HTTP protocol, headers are case-insensitive. This means that content-type, Content-Type, and coNTEnt-tYPe all refer to the same header, and the Express framework needs to be able to handle any of them. The different between req.headers (the object) and req.header (the function) is simply this: If you want to get … Read more