Getting started with io.js


Before doing this tutorial you should have setup your environment:

All the operation achieved with the 'scalingo' CLI can also be done on our web dashbaord.

Initialize your application

$ mkdir iojs-app
$ cd iojs-app
$ npm init

# You need to fill the different info field for your project

$ npm install express --save
$ echo "node_modules" > .gitignore

Write a base server file


// Node.js - Express Sample application

var express = require('express')
var app = express()

app.get('/', function (req, res) {
  res.send('Hello World!')

var server = app.listen(process.env.PORT || 3000, function () {
  var host = server.address().address
  var port = server.address().port
  console.log('App listening at http://%s:%s', host, port)
The `process.env.PORT` will read the environment variable PORT dynamically provided by our container manager.

Define how to start your application


web: iojs server.js

Define io.js as javascript engine

In your package.json, add the following block:

"engines": {
  "iojs": "1.1.x"

This will instruct the deployment scripts to install iojs at the given version instead of Node.js

Commit your application

$ git init
$ git add .
$ git commit -m "Base io.js application"

Create your application on Scalingo and deploy

This operation has to be done in the directory of your project.

$ scalingo create iojs-app
Git repository detected: remote scalingo added
→ 'git push scalingo master' to deploy your app

$ git push scalingo master

Access your application

Waiting for your application to boot...
<-- -->

Now develop your project and build something amazing!

schedule 09 Feb 2015