diff --git a/README.md b/README.md index 2f8d633..ae2afd8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,34 @@ # StackMonkey Various monkey apps for stack and bluemix + + +# Node.js Starter Application + +Bluemix provides a Node.js starter application as a template so that you can add your code and push the changes back to the Bluemix environment. + + +## Files + +The Node.js starter application has files as below: + +* instructions.md + + This file describes the Next Steps for getting started with this template. + +* app.js + + This file contains the server side JavaScript code for your application written using the Node.js API + +* views/ + + This directory contains the views of the application. It is required by the express framework and jade template engine in this sample application. + +* public/ + + This directory contains public resources of the application. It is required by the express framework in this sample application. + +* package.json + + This file is required by the Node.js environment. It specifies this Node.js project name, dependencies, and other configurations of your Node.js application. + + diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..bdd7a59 --- /dev/null +++ b/README.txt @@ -0,0 +1,30 @@ +# Node.js Starter Application + +Bluemix provides a Node.js starter application as a template so that you can add your code and push the changes back to the Bluemix environment. + + +## Files + +The Node.js starter application has files as below: + +* instructions.md + + This file describes the Next Steps for getting started with this template. + +* app.js + + This file contains the server side JavaScript code for your application written using the Node.js API + +* views/ + + This directory contains the views of the application. It is required by the express framework and jade template engine in this sample application. + +* public/ + + This directory contains public resources of the application. It is required by the express framework in this sample application. + +* package.json + + This file is required by the Node.js environment. It specifies this Node.js project name, dependencies, and other configurations of your Node.js application. + + diff --git a/app.js b/app.js new file mode 100644 index 0000000..f289eb3 --- /dev/null +++ b/app.js @@ -0,0 +1,41 @@ +/*jshint node:true*/ + +// app.js +// This file contains the server side JavaScript code for your application. +// This sample application uses express as web application framework (http://expressjs.com/), +// and jade as template engine (http://jade-lang.com/). + +var express = require('express'); + +// setup middleware +var app = express(); +app.use(app.router); +app.use(express.errorHandler()); +app.use(express.static(__dirname + '/public')); //setup static public directory +app.set('view engine', 'jade'); +app.set('views', __dirname + '/views'); //optional since express defaults to CWD/views + +// render index page +app.get('/', function(req, res){ + res.render('index'); +}); + +// There are many useful environment variables available in process.env. +// VCAP_APPLICATION contains useful information about a deployed application. +var appInfo = JSON.parse(process.env.VCAP_APPLICATION || "{}"); +// TODO: Get application information and use it in your app. + +// VCAP_SERVICES contains all the credentials of services bound to +// this application. For details of its content, please refer to +// the document or sample of each service. +var services = JSON.parse(process.env.VCAP_SERVICES || "{}"); +// TODO: Get service credentials and communicate with bluemix services. + +// The IP address of the Cloud Foundry DEA (Droplet Execution Agent) that hosts this application: +var host = (process.env.VCAP_APP_HOST || 'localhost'); +// The port on the DEA for communication with the application: +var port = (process.env.VCAP_APP_PORT || 3000); +// Start server +app.listen(port, host); +console.log('App started on port ' + port); + diff --git a/instructions/de/instructions.md b/instructions/de/instructions.md new file mode 100644 index 0000000..1a459c2 --- /dev/null +++ b/instructions/de/instructions.md @@ -0,0 +1,24 @@ +Einführung in ${app} +----------------------------------- +Willkommen bei Ihrer neuen Node.js-Anwendung! + +Die Node.js-Anwendung wird in einer serverseitigen, stark skalierbaren, ereignisgesteuerten Hochleistungsumgebung mit nicht blockierender E/A ausgeführt, die in der Programmiersprache JavaScript geschrieben ist. + +1. [Das Befehlszeilentool 'cf' installieren](${doc-url}/#starters/BuildingWeb.html#install_cf). +2. [Das Starteranwendungspaket herunterladen](${ace-url}/rest/apps/${app-guid}/starter-download). +3. Das Paket extrahieren und nach `cd` wechseln. +4. Verbindung zu Bluemix herstellen: + + cf api ${api-url} + +5. Bei Bluemix anmelden: + + cf login -u ${username} + cf target -o ${org} -s ${space} + +6. Ihre Anwendung (App) bereitstellen: + + cf push ${app} + +7. Auf Ihre Anwendung (App) zugreifen: [${route}](//${route}) + diff --git a/instructions/es/instructions.md b/instructions/es/instructions.md new file mode 100644 index 0000000..66ac973 --- /dev/null +++ b/instructions/es/instructions.md @@ -0,0 +1,24 @@ +Empiece a trabajar con ${app} +----------------------------------- +Bienvenido a su nueva app Node.js. + +La app Node.js se ejecuta en un entorno de alto rendimiento del lado del servidor, altamente escalable y controlado por eventos, con un sistema de E/S sin bloqueo programado con el lenguaje de programación JavaScript. + +1. [Instale la herramienta de línea de mandatos cf](${doc-url}/#starters/BuildingWeb.html#install_cf). +2. [Descargue el paquete de aplicación de inicio](${ace-url}/rest/apps/${app-guid}/starter-download). +3. Extraiga el paquete y ejecute `cd` para ir al mismo. +4. Conéctese a Bluemix: + + cf api ${api-url} + +5. Inicie la sesión en Bluemix: + + cf login -u ${username} + cf target -o ${org} -s ${space} + +6. Despliegue su app: + + cf push ${app} + +7. Acceda a la app: [${ruta}](//${route}) + diff --git a/instructions/fr/instructions.md b/instructions/fr/instructions.md new file mode 100644 index 0000000..8b956dd --- /dev/null +++ b/instructions/fr/instructions.md @@ -0,0 +1,26 @@ +Initiation à ${app} +----------------------------------- +Bienvenue dans votre nouvelle application Node.js ! + +L'application Node.js s'exécute dans un environnement géré par des événements, hautement évolutif et très performant côté serveur avec une +entrée-sortie non bloquante en langage de programmation JavaScript. + + +1. [Installez l'outil de ligne de commande cf](${doc-url}/#starters/BuildingWeb.html#install_cf). +2. [Téléchargez le package d'applications du module de démarrage](${ace-url}/rest/apps/${app-guid}/starter-download). +3. Procédez à l'extraction du package et placez-vous dans le répertoire correspondant à l'aide de la commande `cd`. +4. Accédez à Bluemix : + + cf api ${url-api} + +5. Connectez-vous à Bluemix : + + cf login -u ${nom-utilisateur} + cf target -o ${org} -s ${espace} + +6. Déployez votre application : + + cf push ${app} + +7. Accédez à votre application : [${route}](//${route}) + diff --git a/instructions/instructions.md b/instructions/instructions.md new file mode 100644 index 0000000..b34d567 --- /dev/null +++ b/instructions/instructions.md @@ -0,0 +1,24 @@ +Get started with StackMonkey +----------------------------------- +Welcome to your new Node.js app! + +Node.js app runs on a server-side high performance, highly scalable, event-driven environment with non-blocking I/O that is programmed with the JavaScript programming language. + +1. [Install the cf command-line tool](https://www.ng.bluemix.net/docs/#starters/BuildingWeb.html#install_cf). +2. [Download the starter application package](https://console.ng.bluemix.net:443/rest/../rest/apps/87e82ab0-d0bd-4dc7-aca4-0ae5d58c33d1/starter-download). +3. Extract the package and `cd` to it. +4. Connect to Bluemix: + + cf api https://api.ng.bluemix.net + +5. Log into Bluemix: + + cf login -u rolf-bm@tuis.net + cf target -o rolf-bm@tuis.net -s dev + +6. Deploy your app: + + cf push StackMonkey + +7. Access your app: [stackmonkey.mybluemix.net](//stackmonkey.mybluemix.net) + diff --git a/instructions/it/instructions.md b/instructions/it/instructions.md new file mode 100644 index 0000000..4dd7173 --- /dev/null +++ b/instructions/it/instructions.md @@ -0,0 +1,24 @@ +Introduzione a ${app} +----------------------------------- +Benvenuti nella nuova app Node.js! + +La app Node.js viene eseguita in un ambiente basato su eventi, altamente scalabile e ad elevate prestazioni sul lato server con I/O non bloccante programmato con il linguaggio JavaScript. + +1. [Installare lo strumento della riga di comando cf](${doc-url}/#starters/BuildingWeb.html#install_cf). +2. [Scaricare il package applicazione starter](${ace-url}/rest/apps/${app-guid}/starter-download). +3. Estrarre il package e `cd`. +4. Connetti a Bluemix: + + cf api ${api-url} + +5. Accedi a Bluemix: + + cf login -u ${username} + cf target -o ${org} -s ${space} + +6. Distribuisci la app: + + cf push ${app} + +7. Accedi alla app: [${route}](//${route}) + diff --git a/instructions/ja/instructions.md b/instructions/ja/instructions.md new file mode 100644 index 0000000..cab6b9e --- /dev/null +++ b/instructions/ja/instructions.md @@ -0,0 +1,24 @@ +${app}: 始めに +----------------------------------- +新しい Node.js アプリへようこそ + +Node.js アプリは、サーバー・サイドのハイパフォーマンス、ハイ・スケーラブルなイベント・ドリブン環境で実行され、JavaScript プログラミング言語でプログラミングされるノンブロッキング I/O が使用されます。 + +1. [cf コマンド・ライン・ツールをインストールします](${doc-url}/#starters/BuildingWeb.html#install_cf)。 +2. [スターター・アプリケーション・パッケージをダウンロードします](${ace-url}/rest/apps/${app-guid}/starter-download)。 +3. パッケージを解凍し、そのパッケージに `cd` で移動します。 +4. Bluemix への接続: + + cf api ${api-url} + +5. Bluemix へのログイン: + + cf login -u ${username} + cf target -o ${org} -s ${space} + +6. アプリのデプロイ: + + cf push ${app} + +7. アプリへのアクセス: [${route}](//${route}) + diff --git a/instructions/pt-br/instructions.md b/instructions/pt-br/instructions.md new file mode 100644 index 0000000..e736292 --- /dev/null +++ b/instructions/pt-br/instructions.md @@ -0,0 +1,24 @@ +Introdução ao ${app} +----------------------------------- +Bem-vindo ao novo app Node.js! + +O app Node.js é executado em um ambiente acionado por evento, altamente escalável e de alto desempenho do lado do servidor com E/S sem bloqueio que é programada com a linguagem de programação JavaScript. + +1. [Instale a ferramenta de linha de comandos cf](${doc-url}/#starters/BuildingWeb.html#install_cf). +2. [Faça o download do pacote de aplicativo iniciador](${ace-url}/rest/apps/${app-guid}/starter-download). +3. Extraia o pacote e `cd` para ele. +4. Conecte-se ao Bluemix: + + cf api ${api-url} + +5. Efetue login no Bluemix: + + cf login -u ${username} + cf target -o ${org} -s ${space} + +6. Implemente seu app: + + cf push ${app} + +7. Acesse seu app: [${route}](//${route}) + diff --git a/instructions/zh-cn/instructions.md b/instructions/zh-cn/instructions.md new file mode 100644 index 0000000..8aca3ab --- /dev/null +++ b/instructions/zh-cn/instructions.md @@ -0,0 +1,23 @@ +${app} 入门 +----------------------------------- +欢迎使用新 Node.js 应用程序! +Node.js 应用程序在服务器端的高性能、可高度扩展、以事件驱动的环境中运行,该环境具有以 JavaScript 编程语言编写的非阻塞的 I/O。 + +1. [安装 cf 命令行工具](${doc-url}/#starters/BuildingWeb.html#install_cf)。 +2. [下载起动器应用程序包](${ace-url}/rest/apps/${app-guid}/starter-download)。 +3. 将程序包和 `cd` 抽取到它。 +4. 连接到 Bluemix: + + cf api ${api-url} + +5. 登录到 Bluemix: + + cf login -u ${username} + cf target -o ${org} -s ${space} + +6. 部署您的应用程序: + + cf push ${app} + +7. 访问您的应用程序:[${route}](//${route}) + diff --git a/instructions/zh-tw/instructions.md b/instructions/zh-tw/instructions.md new file mode 100644 index 0000000..817baa1 --- /dev/null +++ b/instructions/zh-tw/instructions.md @@ -0,0 +1,24 @@ +開始使用 ${app} +----------------------------------- +歡迎使用您的新 Node.js 應用程式! + +Node.js 應用程式在伺服器端的高效能、高度可調整、事件驅動的環境上執行,且使用以 JavaScript 程式設計語言設計的非阻擋式 I/O。 + +1. [安裝 cf 指令行工具](${doc-url}/#starters/BuildingWeb.html#install_cf)。 +2. [下載入門範本應用程式套件](${ace-url}/rest/apps/${app-guid}/starter-download)。 +3. 解開套件並 `cd` 到該處。 +4. 連接至 Bluemix: + + cf api ${api-url} + +5. 登入 Bluemix: + + cf login -u ${username} + cf target -o ${org} -s ${space} + +6. 部署您的應用程式: + + cf push ${app} + +7. 存取您的應用程式:[${route}](//${route}) + diff --git a/manifest.yml b/manifest.yml new file mode 100644 index 0000000..144cea3 --- /dev/null +++ b/manifest.yml @@ -0,0 +1,9 @@ +applications: +- disk_quota: 1024M + host: stackmonkey + name: StackMonkey + command: node app.js + path: . + domain: mybluemix.net + instances: 1 + memory: 128M diff --git a/package.json b/package.json new file mode 100644 index 0000000..48cdd69 --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "NodejsStarterApp", + "version": "0.0.1", + "description": "A sample nodejs app for Bluemix", + "dependencies": { + "express": "3.4.7", + "jade": "1.1.4" + }, + "engines": { + "node": "0.10.*" + }, + "repository": {} +} diff --git a/public/images/newapp-icon.png b/public/images/newapp-icon.png new file mode 100644 index 0000000..41cf02f Binary files /dev/null and b/public/images/newapp-icon.png differ diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css new file mode 100644 index 0000000..995c2dc --- /dev/null +++ b/public/stylesheets/style.css @@ -0,0 +1,82 @@ +/* style.css + * This file provides css styles. + */ + +body,html { + background-color: #3b4b54; width : 100%; + height: 100%; + margin: 0 auto; + font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + color: #ffffff; +} + +a { + text-decoration: none; + color: #00aed1; +} + +a:hover { + text-decoration: underline; +} + +img { + padding-top: 10%; + display: block; + margin: 0 auto; + padding-bottom: 2em; + max-width:200px; +} + +h1 { + font-weight: bold; + font-size: 2em; +} + +.leftHalf { + float: left; + background-color: #26343f; + width: 45%; + height: 100%; +} + +.rightHalf { + float: right; + width: 55%; + background-color: #313f4a; + height: 100%; + overflow:auto; +} + +.blue { + color: #00aed1; +} + + +table { + table-layout: fixed; + width: 800px; + margin: 0 auto; + word-wrap: break-word; + padding-top:10%; +} + +th { + border-bottom: 1px solid #000; +} + +th, td { + text-align: left; + padding: 2px 20px; +} + +.env-var { + text-align: right; + border-right: 1px solid #000; + width: 30%; +} + +pre { + padding: 0; + margin: 0; +} + diff --git a/views/body.jade b/views/body.jade new file mode 100644 index 0000000..0283902 --- /dev/null +++ b/views/body.jade @@ -0,0 +1,12 @@ +//- body.jade +//- This file provides the HTML body part. + + +body + table + tr + td(style= "width:30%;" ) + img(src="/images/newapp-icon.png") + td + h1 Hi there! + p Thanks for creating a NodeJS Starter Application. Get started by reading our documentation or use the Start Coding guide under your app in your dashboard. diff --git a/views/head.jade b/views/head.jade new file mode 100644 index 0000000..575920a --- /dev/null +++ b/views/head.jade @@ -0,0 +1,8 @@ +//- head.jade +//- This file provides the HTML head part + +head + title NodeJS Starter Application + meta(http-equiv="Content-Type", content="text/html; charset=utf-8") + link(rel="stylesheet", href="/stylesheets/style.css") + diff --git a/views/index.jade b/views/index.jade new file mode 100644 index 0000000..794a43e --- /dev/null +++ b/views/index.jade @@ -0,0 +1,8 @@ +//- index.jade +//- This file defines the view of this app. + +doctype html +html + include head + include body +