Por дефекто Cloud9 C9.io Viene Instalado por Defecto Con Express pero podemos instalar hapiJs.

Кремос эль package.json с эль siguiente команда:

npm init

Установите и защитите зависимости от package.json:

npm install hapi --save

Создание js с номером server.js с основным кодом:

'use strict';
const Hapi = require('hapi');
// Create a server with a host and port
const server = new Hapi.Server();
server.connection({ 
    host: process.env.IP, 
    port: process.env.PORT || 3000 
});
// Add the route
server.route({
    method: 'GET',
    path:'/hello', 
    handler: function (request, reply) {
        return reply('hello world');
    }
});
// Start the server
server.start((err) => {
if (err) {
        throw err;
    }
    console.log('Server running at:', server.info.uri);
});

El anterior ejemplo es sencillo y solo funciona en c9.io si cambiamos el puerto y su ip este es la clave.

const server = new Hapi.Server();
server.connection({ 
    host: process.env.IP, 
    port: process.env.PORT || 3000 
});

por ultimo ejecutamos en la consola

npm start
> [email protected] start /home/ubuntu/workspace
> node server.js
Server running at: http://0.0.0.0:8080

En el navegador Preview для c9.io