On returning content # automagically detects content and set the right headers: res.send(returnhere) # explicitly return json objects: res.json(JSON.stringify(returnhere)) # you are more interested in sending http codes than actual return objects:
Category Archives: node.js
boostrapping a MEAN app (angular.js, express, node.js, mongodb)
Complete code example here – in the folder you are creating your app, place a manifest file called package.json, example: { “name”: “yourappnamehere” } – install express and other dependencies: $ sudo apt-get update $ sudo apt-get install npm $ sudo apt-get install nodejs Note: copying and pasting these commands sometimes will give you the following error message: […]
node.js: boilerplating a site with express.js
Install express globally in your system, so you can use it from anywhere: $npm install -g express Initialize your installation: $express myapp; cd myapp; Modify your package.json file inside of there, and run it. Here’s a boilerplate example of it: { “name”: “nameofyourapphere”, “version”: “0.0.1”, “description”: “”, “main”: “index.js”, “scripts”: { “test”: “echo “Error: no […]
Node.js: an app example using Yahoo geolocation service, and request library
This is a bad copy for personal use. The original series / tutorial here: https://thenewcircle.com/s/post/1534/nodejs_tutorial_videos_geolocation_app?utm_source=javascriptweekly&utm_medium=email 1) Make sure node and npm are installed: $node –version $npm –version 2) Setup a local space for your project $mkdir myapp; cd myapp; $npm install express Since we are not using -g to install this globally, this express installation […]
node.js: API
global — The equivalent of window in the browser. process.nextTick(cbfunction); // Schedule a function callback for the next time the loop goes around console.log and console.error // Same as in firebug
node.js: how it is different from other web platforms
Node has a single thread, looping on itself to handle requests. Unlike PHP and other platforms, where each request spawn its own thread. This means: if a request modify a variable with global scope, the modified variable will be served in the next request. Node process in a nutshell: loop taking request (running in infinite […]
Node.js: the basics
Install node.js (no need to be verbose, see website for more details) $ node -v // Verify installation Install the NPM (node package manager, this will allow you to install and manage node packages): $ curl http://npmjs.org/install.sh | sh $ npm –version // Verify version and installation of package manager Creating your application and installing […]