SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Node.js in Action
Simon Su @ MiCloud
Objective
● Node.js Installation
● Node.js Basic
● Node.js Web Framework - Express
Install Node.js
● Download source code
● Install
tar -zxf node-vx.x.x.tar.gz
cd node-vx.x.x
./configure
./configure --prefix=/opt/node
make
sudo make install
Node.js install - Install from Source
● Mac安裝Node.js:
○ Mac版本安裝程式為node-vx.x.x.pkg,執行pkg安裝程式後,將會有安裝
程序帶領您安裝完Node.js
○ 其他安裝支援:MacPort, homebrew
● SmartOS安裝Node.js:
○ pkgin search node
○ pkgin install nodejs-0.4.9
● Windows安裝Node.js:
○ v0.6.x前安裝Node.js於Windows上必須先行安裝 cygwin 然後採用
source install方式安裝
○ v0.6.x後提供msi安裝檔案
Node.js install - All OS
Node.js install - v0.6.8+ support
Node.js vs Javascript
Node.js vs Javascript
Node.js
● Server side language
JavaScript
● Client side language
Node.js Basic
Node.js Read-Eval-Print-Loop (REPL)
$ node
> var os=require('os');
undefined
> os.hostname()
'SimonAIR.local'
>
undefined
>
(^C again to quit)
>
$
指令列直接執行node
鍵入測試指令
使用Ctri + C (兩次) 離開
Basic of Node - 基本語法
● 載入模組
var http = require('http');
● 分享模組
export
module.export
● 註解
// This is a common
/* This is a common */
● 變數
name = value //global
var name = value
● 執行
node nodejs-file-name.js
● 全域物件(Global Objects)
● global
● process
● console
● Buffer
● require()
● require.resolve()
● require.cache
● __filename
● __dirname
● module
● exports
● setTimeout(cb, ms)
● clearTimeout(t)
● setInterval(cb, ms)
● clearInterval(t)
Basic of Node - Exception
$ node 003-for3.js
/Users/jellychang/Workspaces/NodeWS/Sample/003-for3.js:1
process.argv ){
^
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Unexpected token )
at Module._compile (module.js:427:25)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
錯誤程式區段與位置資訊
Stack trace
Stack trace DETAIL
錯誤原因
Basic of Node - Language Core
● 順序 (Sequence)
● 判斷 (If ... Then .... Else ....)
● 迴圈 (Loops)
Basic of Node -
Non-Block vs Sequence
$ cat 000-sequence.js
console.log('The start of node...');
for(i = 0; i< 3 ; i++ ){
console.log('=>' + i);
}
console.log('The end of node...');
$ node 000-sequence.js
The start of node...
=>0
=>1
=>2
The end of node...
#cat 000-nonblock2.js
setTimeout(function(){
console.log("bar...");
}, 1000);
console.log("foo...");
$ node 000-unblock2.js
foo... (will wait...)
bar...
Basic of Node - if condition
if (CONDITION) {
RULE
} else if {
RULE
} else {
RULE
}
#!/usr/bin/env node
//003-if.js
if ( process.argv[2] == 1 ) {
console.log('input 1...');
} else if (process.argv[2] == 2) {
console.log('input 2...');
} else {
console.log('not 1 or 2...');
}
$ ./003-if.js
not 1 or 2...
$ ./003-if.js 1
input 1...
$ ./003-if.js 2
input 2...
Basic of Node - switch
switch ( EVENT ) {
case EVENT_VALUE:
PROCESS
break;
... (other case)
default:
PROCESS
break;
}
#003-switch.js
console.log('-->' + process.argv[2]);
switch ( process.argv[2] ) {
case '1':
console.log('==>1');
break;
case '10':
console.log('==>10');
break;
default:
console.log('default...');
break;
}
$ node 003-switch.js 1
-->1
==>1
Basic of Node - for loop
for ( i in SET ) {
PROCESS...
}
#003-for.js
for ( i in process.argv ){
console.log('-->' + i +
'=' + process.argv[i]);
}
$ node 003-for.js 1 2 3
-->0=node
-->1=/.../Sample/003-for.js
-->2=1
-->3=2
-->4=3
Basic of Node - for loop
for ( KEY=VALUE;
BREAK_CONDITION;
BREAK_RULE) {
PROCESS
}
#003-for2.js
for ( i=0 ; i < 5 ; i++ ){
console.log(i);
}
$ node 003-for2.js
0
1
2
3
4
Basic of Node - while loop
while ( CONDITION ){
PROCESS
[BREAK_RULE]
}
$ cat 003-while.js
i = 5;
while(i < process.argv[2]){
console.log('-->' + i);
i++;
}
$ node 003-while.js 10
-->5
-->6
-->7
-->8
-->9
Node Ecosystem - NPM
Node Package Management
Install NPM
● >= Node.js 0.6.*
○ Congratulation, in already included in the Node.js
● < Node.js 0.6.*
● One Line Install
curl http://npmjs.org/install.sh | sh
● More Than One Line Install
○ Get the code... https://github.com/isaacs/npm
○ Make & Make install it...
● Windows Install
○ Download a zip file from http://npmjs.org/dist/
○ Unpack it in the same folder where node.exe
lives
NPM Basic Usage
Search:
npm search [some search terms ...]
ex: npm search express
Install:
npm install <name>
ex: npm install express
● Remove:
npm uninstall <name>[@<version> [<name>[@<version>]...]
ex: npm uninstall express
NPM advance commands
● npm list
List the detail help contents
● npm install <pkg. name> -gd
Install the package into global folder.
○ Basicly, the npm install <pkg. name> will install the
package into the user home directory, like:
$HOME/node_modules/*
○ Npm related information will store in $HOME/.npm
Best NPM packages
● View module: jade, express, ejs
● MySQL connector: mysql
● Mailer: nodemailer
● NoSQL: felix-couchdb, mongodb
Node.js Web Fraework -
Express / Ejs
Basic Web Server
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Worldn');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
3Steps using express/ejs framework
1. Install express, ejs, jade
npm install express ejs jade -gd
PS: Install specific version of module
npm install express@2.5.9 [-gd]
2. Create your project
express <your project name>
ex: express TestPrj
3. Sync project module
cd <your project name> && npm install
ex: cd TestPrj && npm install
Testing of Created Project
# cd $YOUR_WORKSPACE/TestPrj
# node app.js
# cd $YOUR_WORKSPACE/TestPrj
# ls -ltr
總計 24
drwxr-xr-x 5 root root 316 2012-03-30 00:41 public
drwxr-xr-x 2 root root 182 2012-03-30 00:41 routes
drwxr-xr-x 2 root root 252 2012-03-30 00:41 views
-rw-r--r-- 1 root root 153 2012-03-30 00:41 package.json
-rw-r--r-- 1 root root 783 2012-03-30 00:41 app.js
drwxr-xr-x 5 root root 303 2012-03-30 00:41 node_modules
# node app.js
Express server listening on port 3000 in development mode
Using ejs as View Engine - Config
//file: app.js
//Configure route setting
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.cookieParser());
//app.use(express.session({ secret: "keyboard cat" }));
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
app.set("view options", {layout : true});
});
//Configure routing
app.get('/', function(req, res){
res.render('index', {
title: 'Express'
});
});
var express = require('express')
, routes = require('./routes');
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions:
true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
// Routes
app.get('/', routes.index);
app.listen(3000, function(){
console.log("Express server listening on port %d in
%s mode", app.address().port, app.settings.env);
});
Using ejs as View Engine - layout
/* file: /view/layout.ejs */
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<!-- /page -->
<div data-role="page">
<!-- /header -->
<div data-role="header">
<h1>My Title</h1>
</div>
<!-- /content -->
<%- body %>
</div>
</body>
</html>
!!!
html
head
title= title
link(rel='stylesheet',
href='/stylesheets/style.css')
body
block content
Using ejs as View Engine - View
/* file: /view/index.ejs */
<h1><%= title %></h1>
<p>Welcome to <%= title %></p>
extends layout
block content
h1= title
p Welcome to #{title}
Configure REST routing
// file: app.js
app.get('/getUsedExam/:classid', refEngin.getUsedExam);
app.get('/getUsedExam/:classid/:teacherid', refEngin.getUsedExam);
app.get('/getUsedExam/:classid/:teacherid/:examid', refEngin.getUsedExam);
// file: routes/someRouter.js
exports.getUserdExam = function(req, res, next) {
var classid = req.params.classid;
...(skip)
console.log('classid: ' + classid );
res.render('simeViewEjsFile', {result: classid});
});
};
Node.js MySQL
Connector
Installing MySQL connector
$ npm install mysql
npm http GET https://registry.npmjs.org/mysql
npm http 304 https://registry.npmjs.org/mysql
npm http GET https://registry.npmjs.org/hashish/0.0.4
npm http 304 https://registry.npmjs.org/hashish/0.0.4
npm http GET https://registry.npmjs.org/traverse
npm http 304 https://registry.npmjs.org/traverse
mysql@0.9.5 ./node_modules/mysql
└── hashish@0.0.4
Using MySQL connector - Config
$ vi mysql-config.js
var db_options = {
host: 'your.database.address',
port: your_database_port,
user: 'access_database_name',
password: 'access_database_password',
database: 'database_that_will_be_use'
};
var mysql = new require('mysql'), db = null;
if(mysql.createClient) {
db = mysql.createClient(db_options);
} else {
db = new mysql.Client(db_options);
db.connect(function(err) {
if(err) {
console.error('connect db ' + db.host + ' error: ' + err);
process.exit();
}
});
}
exports.db = db;
/* file: routes/someRoute.js */
var config = require('./mysql-config')
, db = config.db;
exports.checkExamStatus = function(req, res, next) {
var sql = 'select * from some_talbe a where a.some_column = ? and a.some_column2 = ?';
var some_condition = req.params.some_condition;
var cond = [some_condition, some_condition2];
console.log('Query: ' + sql );
console.log('Cond: ' + cond);
db.query(sql, cond, function(err, rows, fiels) {
if(err) return next(err);
res.render('simpleJsonResult', {result: rows});
});
};
/* file: view/simpleJsonResult.ejs */
<%-JSON.stringify(result)%>
Using MySQL connector - Query
/* file: routes/someRoute.js */
var config = require('./mysql-config')
, db = config.db;
exports.checkExamStatus = function(req, res, next) {
var sql = 'select * from some_talbe a where 1=1 ';
var some_condition = req.params.some_condition;
var cond = new Array();
if (req.params.some_condition != null) {
sql += ' and a.some_column = ? ';
cond.push(some_condition);
}
console.log('Query: ' + sql );
console.log('Cond: ' + cond);
db.query(sql, cond, function(err, rows, fiels) {
if(err) return next(err);
res.render('simpleJsonResult', {result: rows});
});
};
Using MySQL connector - Query 2
Enjoy Your Node
END

Weitere ähnliche Inhalte

Was ist angesagt?

Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Railsrstankov
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptJon Kruger
 
¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?jaespinmora
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperJon Kruger
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwrdeimos
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensionserwanl
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuerydeimos
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreRemy Sharp
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRaimonds Simanovskis
 
History of jQuery
History of jQueryHistory of jQuery
History of jQueryjeresig
 
PHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkPHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkG Woo
 
JavaScript
JavaScriptJavaScript
JavaScriptSunil OS
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginningAnis Ahmad
 

Was ist angesagt? (20)

Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScript
 
¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwr
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
CodeIgniter 3.0
CodeIgniter 3.0CodeIgniter 3.0
CodeIgniter 3.0
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuery
 
Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async Patterns
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
History of jQuery
History of jQueryHistory of jQuery
History of jQuery
 
PHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkPHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php framework
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
HTML,CSS Next
HTML,CSS NextHTML,CSS Next
HTML,CSS Next
 
JavaScript
JavaScriptJavaScript
JavaScript
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 

Andere mochten auch

Extending built in objects
Extending built in objectsExtending built in objects
Extending built in objectsMuhammad Ahmed
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript BasicsMindfire Solutions
 
Js interpreter interpreted
Js interpreter interpretedJs interpreter interpreted
Js interpreter interpretedMartha Schumann
 
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
#7 "Многообещающий JavaScript – Promises" Денис Речкунов#7 "Многообещающий JavaScript – Promises" Денис Речкунов
#7 "Многообещающий JavaScript – Promises" Денис РечкуновJSib
 
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...Calvin Tan
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseAaron Silverman
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptecker
 
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
Burgas Conf 21.06.2014 - Single page application Angularjs and NodejsBurgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
Burgas Conf 21.06.2014 - Single page application Angularjs and NodejsDimitar Danailov
 
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)raja kvk
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event LoopDesignveloper
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejsAmit Thakkar
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJSHüseyin BABAL
 
Nodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web ApplicationsNodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web ApplicationsGanesh Iyer
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs Irfan Maulana
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Visual Engineering
 
Debugging node in prod
Debugging node in prodDebugging node in prod
Debugging node in prodYunong Xiao
 

Andere mochten auch (20)

Extending built in objects
Extending built in objectsExtending built in objects
Extending built in objects
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
Array
ArrayArray
Array
 
Js interpreter interpreted
Js interpreter interpretedJs interpreter interpreted
Js interpreter interpreted
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
#7 "Многообещающий JavaScript – Promises" Денис Речкунов#7 "Многообещающий JavaScript – Promises" Денис Речкунов
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
 
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash Course
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScript
 
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
Burgas Conf 21.06.2014 - Single page application Angularjs and NodejsBurgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
 
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
Nodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web ApplicationsNodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web Applications
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 
Debugging node in prod
Debugging node in prodDebugging node in prod
Debugging node in prod
 

Ähnlich wie Node.js in action

Nodejs quick start
Nodejs quick startNodejs quick start
Nodejs quick startGuangyao Cao
 
Introduction to Node js for beginners + game project
Introduction to Node js for beginners + game projectIntroduction to Node js for beginners + game project
Introduction to Node js for beginners + game projectLaurence Svekis ✔
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLaurence Svekis ✔
 
Nodejs first class
Nodejs first classNodejs first class
Nodejs first classFin Chen
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploySimon Su
 
Gr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
Gr8conf EU 2018 - Bring you infrastructure under control with InfrastructorGr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
Gr8conf EU 2018 - Bring you infrastructure under control with InfrastructorStanislav Tiurikov
 
Build Web Apps using Node.js
Build Web Apps using Node.jsBuild Web Apps using Node.js
Build Web Apps using Node.jsdavidchubbs
 
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Cosimo Streppone
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008phpbarcelona
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with PuppetKris Buytaert
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)Ashish Gupta
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Carlos Sanchez
 

Ähnlich wie Node.js in action (20)

Nodejs quick start
Nodejs quick startNodejs quick start
Nodejs quick start
 
Introduction to Node js for beginners + game project
Introduction to Node js for beginners + game projectIntroduction to Node js for beginners + game project
Introduction to Node js for beginners + game project
 
Node js
Node jsNode js
Node js
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginners
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
 
Nodejs first class
Nodejs first classNodejs first class
Nodejs first class
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploy
 
Gr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
Gr8conf EU 2018 - Bring you infrastructure under control with InfrastructorGr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
Gr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
 
Build Web Apps using Node.js
Build Web Apps using Node.jsBuild Web Apps using Node.js
Build Web Apps using Node.js
 
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Book
BookBook
Book
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
 
Write php deploy everywhere tek11
Write php deploy everywhere   tek11Write php deploy everywhere   tek11
Write php deploy everywhere tek11
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 

Mehr von Simon Su

Kubernetes Basic Operation
Kubernetes Basic OperationKubernetes Basic Operation
Kubernetes Basic OperationSimon Su
 
Google IoT Core 初體驗
Google IoT Core 初體驗Google IoT Core 初體驗
Google IoT Core 初體驗Simon Su
 
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoTJSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoTSimon Su
 
GCPUG.TW meetup #28 - GKE上運作您的k8s服務
GCPUG.TW meetup #28 - GKE上運作您的k8s服務GCPUG.TW meetup #28 - GKE上運作您的k8s服務
GCPUG.TW meetup #28 - GKE上運作您的k8s服務Simon Su
 
Google Cloud Platform Special Training
Google Cloud Platform Special TrainingGoogle Cloud Platform Special Training
Google Cloud Platform Special TrainingSimon Su
 
GCE Windows Serial Console Usage Guide
GCE Windows Serial Console Usage GuideGCE Windows Serial Console Usage Guide
GCE Windows Serial Console Usage GuideSimon Su
 
GCPNext17' Extend 開始GCP了嗎?
GCPNext17' Extend   開始GCP了嗎?GCPNext17' Extend   開始GCP了嗎?
GCPNext17' Extend 開始GCP了嗎?Simon Su
 
Try Cloud Spanner
Try Cloud SpannerTry Cloud Spanner
Try Cloud SpannerSimon Su
 
Google Cloud Monitoring
Google Cloud MonitoringGoogle Cloud Monitoring
Google Cloud MonitoringSimon Su
 
Google Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKEGoogle Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKESimon Su
 
JCConf 2016 - Google Dataflow 小試
JCConf 2016 - Google Dataflow 小試JCConf 2016 - Google Dataflow 小試
JCConf 2016 - Google Dataflow 小試Simon Su
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsSimon Su
 
JCConf2016 - Dataflow Workshop Setup
JCConf2016 - Dataflow Workshop SetupJCConf2016 - Dataflow Workshop Setup
JCConf2016 - Dataflow Workshop SetupSimon Su
 
GCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionGCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionSimon Su
 
Brocade - Stingray Application Firewall
Brocade - Stingray Application FirewallBrocade - Stingray Application Firewall
Brocade - Stingray Application FirewallSimon Su
 
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析Simon Su
 
Docker in Action
Docker in ActionDocker in Action
Docker in ActionSimon Su
 
Google I/O 2016 Recap - Google Cloud Platform News Update
Google I/O 2016 Recap - Google Cloud Platform News UpdateGoogle I/O 2016 Recap - Google Cloud Platform News Update
Google I/O 2016 Recap - Google Cloud Platform News UpdateSimon Su
 
IThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOpsIThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOpsSimon Su
 
Google Cloud Platform Introduction - 2016Q3
Google Cloud Platform Introduction - 2016Q3Google Cloud Platform Introduction - 2016Q3
Google Cloud Platform Introduction - 2016Q3Simon Su
 

Mehr von Simon Su (20)

Kubernetes Basic Operation
Kubernetes Basic OperationKubernetes Basic Operation
Kubernetes Basic Operation
 
Google IoT Core 初體驗
Google IoT Core 初體驗Google IoT Core 初體驗
Google IoT Core 初體驗
 
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoTJSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
 
GCPUG.TW meetup #28 - GKE上運作您的k8s服務
GCPUG.TW meetup #28 - GKE上運作您的k8s服務GCPUG.TW meetup #28 - GKE上運作您的k8s服務
GCPUG.TW meetup #28 - GKE上運作您的k8s服務
 
Google Cloud Platform Special Training
Google Cloud Platform Special TrainingGoogle Cloud Platform Special Training
Google Cloud Platform Special Training
 
GCE Windows Serial Console Usage Guide
GCE Windows Serial Console Usage GuideGCE Windows Serial Console Usage Guide
GCE Windows Serial Console Usage Guide
 
GCPNext17' Extend 開始GCP了嗎?
GCPNext17' Extend   開始GCP了嗎?GCPNext17' Extend   開始GCP了嗎?
GCPNext17' Extend 開始GCP了嗎?
 
Try Cloud Spanner
Try Cloud SpannerTry Cloud Spanner
Try Cloud Spanner
 
Google Cloud Monitoring
Google Cloud MonitoringGoogle Cloud Monitoring
Google Cloud Monitoring
 
Google Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKEGoogle Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKE
 
JCConf 2016 - Google Dataflow 小試
JCConf 2016 - Google Dataflow 小試JCConf 2016 - Google Dataflow 小試
JCConf 2016 - Google Dataflow 小試
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop Labs
 
JCConf2016 - Dataflow Workshop Setup
JCConf2016 - Dataflow Workshop SetupJCConf2016 - Dataflow Workshop Setup
JCConf2016 - Dataflow Workshop Setup
 
GCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionGCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow Introduction
 
Brocade - Stingray Application Firewall
Brocade - Stingray Application FirewallBrocade - Stingray Application Firewall
Brocade - Stingray Application Firewall
 
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Google I/O 2016 Recap - Google Cloud Platform News Update
Google I/O 2016 Recap - Google Cloud Platform News UpdateGoogle I/O 2016 Recap - Google Cloud Platform News Update
Google I/O 2016 Recap - Google Cloud Platform News Update
 
IThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOpsIThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOps
 
Google Cloud Platform Introduction - 2016Q3
Google Cloud Platform Introduction - 2016Q3Google Cloud Platform Introduction - 2016Q3
Google Cloud Platform Introduction - 2016Q3
 

Kürzlich hochgeladen

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Node.js in action

  • 1. Node.js in Action Simon Su @ MiCloud
  • 2. Objective ● Node.js Installation ● Node.js Basic ● Node.js Web Framework - Express
  • 4. ● Download source code ● Install tar -zxf node-vx.x.x.tar.gz cd node-vx.x.x ./configure ./configure --prefix=/opt/node make sudo make install Node.js install - Install from Source
  • 5. ● Mac安裝Node.js: ○ Mac版本安裝程式為node-vx.x.x.pkg,執行pkg安裝程式後,將會有安裝 程序帶領您安裝完Node.js ○ 其他安裝支援:MacPort, homebrew ● SmartOS安裝Node.js: ○ pkgin search node ○ pkgin install nodejs-0.4.9 ● Windows安裝Node.js: ○ v0.6.x前安裝Node.js於Windows上必須先行安裝 cygwin 然後採用 source install方式安裝 ○ v0.6.x後提供msi安裝檔案 Node.js install - All OS
  • 6. Node.js install - v0.6.8+ support
  • 8. Node.js vs Javascript Node.js ● Server side language JavaScript ● Client side language
  • 10. Node.js Read-Eval-Print-Loop (REPL) $ node > var os=require('os'); undefined > os.hostname() 'SimonAIR.local' > undefined > (^C again to quit) > $ 指令列直接執行node 鍵入測試指令 使用Ctri + C (兩次) 離開
  • 11. Basic of Node - 基本語法 ● 載入模組 var http = require('http'); ● 分享模組 export module.export ● 註解 // This is a common /* This is a common */ ● 變數 name = value //global var name = value ● 執行 node nodejs-file-name.js ● 全域物件(Global Objects) ● global ● process ● console ● Buffer ● require() ● require.resolve() ● require.cache ● __filename ● __dirname ● module ● exports ● setTimeout(cb, ms) ● clearTimeout(t) ● setInterval(cb, ms) ● clearInterval(t)
  • 12. Basic of Node - Exception $ node 003-for3.js /Users/jellychang/Workspaces/NodeWS/Sample/003-for3.js:1 process.argv ){ ^ node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ SyntaxError: Unexpected token ) at Module._compile (module.js:427:25) at Object..js (module.js:450:10) at Module.load (module.js:351:31) at Function._load (module.js:310:12) at Array.0 (module.js:470:10) at EventEmitter._tickCallback (node.js:192:40) 錯誤程式區段與位置資訊 Stack trace Stack trace DETAIL 錯誤原因
  • 13. Basic of Node - Language Core ● 順序 (Sequence) ● 判斷 (If ... Then .... Else ....) ● 迴圈 (Loops)
  • 14. Basic of Node - Non-Block vs Sequence $ cat 000-sequence.js console.log('The start of node...'); for(i = 0; i< 3 ; i++ ){ console.log('=>' + i); } console.log('The end of node...'); $ node 000-sequence.js The start of node... =>0 =>1 =>2 The end of node... #cat 000-nonblock2.js setTimeout(function(){ console.log("bar..."); }, 1000); console.log("foo..."); $ node 000-unblock2.js foo... (will wait...) bar...
  • 15. Basic of Node - if condition if (CONDITION) { RULE } else if { RULE } else { RULE } #!/usr/bin/env node //003-if.js if ( process.argv[2] == 1 ) { console.log('input 1...'); } else if (process.argv[2] == 2) { console.log('input 2...'); } else { console.log('not 1 or 2...'); } $ ./003-if.js not 1 or 2... $ ./003-if.js 1 input 1... $ ./003-if.js 2 input 2...
  • 16. Basic of Node - switch switch ( EVENT ) { case EVENT_VALUE: PROCESS break; ... (other case) default: PROCESS break; } #003-switch.js console.log('-->' + process.argv[2]); switch ( process.argv[2] ) { case '1': console.log('==>1'); break; case '10': console.log('==>10'); break; default: console.log('default...'); break; } $ node 003-switch.js 1 -->1 ==>1
  • 17. Basic of Node - for loop for ( i in SET ) { PROCESS... } #003-for.js for ( i in process.argv ){ console.log('-->' + i + '=' + process.argv[i]); } $ node 003-for.js 1 2 3 -->0=node -->1=/.../Sample/003-for.js -->2=1 -->3=2 -->4=3
  • 18. Basic of Node - for loop for ( KEY=VALUE; BREAK_CONDITION; BREAK_RULE) { PROCESS } #003-for2.js for ( i=0 ; i < 5 ; i++ ){ console.log(i); } $ node 003-for2.js 0 1 2 3 4
  • 19. Basic of Node - while loop while ( CONDITION ){ PROCESS [BREAK_RULE] } $ cat 003-while.js i = 5; while(i < process.argv[2]){ console.log('-->' + i); i++; } $ node 003-while.js 10 -->5 -->6 -->7 -->8 -->9
  • 20. Node Ecosystem - NPM Node Package Management
  • 21. Install NPM ● >= Node.js 0.6.* ○ Congratulation, in already included in the Node.js ● < Node.js 0.6.* ● One Line Install curl http://npmjs.org/install.sh | sh ● More Than One Line Install ○ Get the code... https://github.com/isaacs/npm ○ Make & Make install it... ● Windows Install ○ Download a zip file from http://npmjs.org/dist/ ○ Unpack it in the same folder where node.exe lives
  • 22. NPM Basic Usage Search: npm search [some search terms ...] ex: npm search express Install: npm install <name> ex: npm install express ● Remove: npm uninstall <name>[@<version> [<name>[@<version>]...] ex: npm uninstall express
  • 23. NPM advance commands ● npm list List the detail help contents ● npm install <pkg. name> -gd Install the package into global folder. ○ Basicly, the npm install <pkg. name> will install the package into the user home directory, like: $HOME/node_modules/* ○ Npm related information will store in $HOME/.npm
  • 24. Best NPM packages ● View module: jade, express, ejs ● MySQL connector: mysql ● Mailer: nodemailer ● NoSQL: felix-couchdb, mongodb
  • 25. Node.js Web Fraework - Express / Ejs
  • 26. Basic Web Server var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');
  • 27. 3Steps using express/ejs framework 1. Install express, ejs, jade npm install express ejs jade -gd PS: Install specific version of module npm install express@2.5.9 [-gd] 2. Create your project express <your project name> ex: express TestPrj 3. Sync project module cd <your project name> && npm install ex: cd TestPrj && npm install
  • 28. Testing of Created Project # cd $YOUR_WORKSPACE/TestPrj # node app.js # cd $YOUR_WORKSPACE/TestPrj # ls -ltr 總計 24 drwxr-xr-x 5 root root 316 2012-03-30 00:41 public drwxr-xr-x 2 root root 182 2012-03-30 00:41 routes drwxr-xr-x 2 root root 252 2012-03-30 00:41 views -rw-r--r-- 1 root root 153 2012-03-30 00:41 package.json -rw-r--r-- 1 root root 783 2012-03-30 00:41 app.js drwxr-xr-x 5 root root 303 2012-03-30 00:41 node_modules # node app.js Express server listening on port 3000 in development mode
  • 29. Using ejs as View Engine - Config //file: app.js //Configure route setting app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); app.use(express.bodyParser()); app.use(express.cookieParser()); //app.use(express.session({ secret: "keyboard cat" })); app.use(express.methodOverride()); app.use(app.router); app.use(express.static(__dirname + '/public')); app.set("view options", {layout : true}); }); //Configure routing app.get('/', function(req, res){ res.render('index', { title: 'Express' }); }); var express = require('express') , routes = require('./routes'); var app = module.exports = express.createServer(); // Configuration app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(app.router); app.use(express.static(__dirname + '/public')); }); app.configure('development', function(){ app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); }); app.configure('production', function(){ app.use(express.errorHandler()); }); // Routes app.get('/', routes.index); app.listen(3000, function(){ console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env); });
  • 30. Using ejs as View Engine - layout /* file: /view/layout.ejs */ <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><%= title %></title> <link rel='stylesheet' href='/stylesheets/style.css' /> </head> <body> <!-- /page --> <div data-role="page"> <!-- /header --> <div data-role="header"> <h1>My Title</h1> </div> <!-- /content --> <%- body %> </div> </body> </html> !!! html head title= title link(rel='stylesheet', href='/stylesheets/style.css') body block content
  • 31. Using ejs as View Engine - View /* file: /view/index.ejs */ <h1><%= title %></h1> <p>Welcome to <%= title %></p> extends layout block content h1= title p Welcome to #{title}
  • 32. Configure REST routing // file: app.js app.get('/getUsedExam/:classid', refEngin.getUsedExam); app.get('/getUsedExam/:classid/:teacherid', refEngin.getUsedExam); app.get('/getUsedExam/:classid/:teacherid/:examid', refEngin.getUsedExam); // file: routes/someRouter.js exports.getUserdExam = function(req, res, next) { var classid = req.params.classid; ...(skip) console.log('classid: ' + classid ); res.render('simeViewEjsFile', {result: classid}); }); };
  • 34. Installing MySQL connector $ npm install mysql npm http GET https://registry.npmjs.org/mysql npm http 304 https://registry.npmjs.org/mysql npm http GET https://registry.npmjs.org/hashish/0.0.4 npm http 304 https://registry.npmjs.org/hashish/0.0.4 npm http GET https://registry.npmjs.org/traverse npm http 304 https://registry.npmjs.org/traverse mysql@0.9.5 ./node_modules/mysql └── hashish@0.0.4
  • 35. Using MySQL connector - Config $ vi mysql-config.js var db_options = { host: 'your.database.address', port: your_database_port, user: 'access_database_name', password: 'access_database_password', database: 'database_that_will_be_use' }; var mysql = new require('mysql'), db = null; if(mysql.createClient) { db = mysql.createClient(db_options); } else { db = new mysql.Client(db_options); db.connect(function(err) { if(err) { console.error('connect db ' + db.host + ' error: ' + err); process.exit(); } }); } exports.db = db;
  • 36. /* file: routes/someRoute.js */ var config = require('./mysql-config') , db = config.db; exports.checkExamStatus = function(req, res, next) { var sql = 'select * from some_talbe a where a.some_column = ? and a.some_column2 = ?'; var some_condition = req.params.some_condition; var cond = [some_condition, some_condition2]; console.log('Query: ' + sql ); console.log('Cond: ' + cond); db.query(sql, cond, function(err, rows, fiels) { if(err) return next(err); res.render('simpleJsonResult', {result: rows}); }); }; /* file: view/simpleJsonResult.ejs */ <%-JSON.stringify(result)%> Using MySQL connector - Query
  • 37. /* file: routes/someRoute.js */ var config = require('./mysql-config') , db = config.db; exports.checkExamStatus = function(req, res, next) { var sql = 'select * from some_talbe a where 1=1 '; var some_condition = req.params.some_condition; var cond = new Array(); if (req.params.some_condition != null) { sql += ' and a.some_column = ? '; cond.push(some_condition); } console.log('Query: ' + sql ); console.log('Cond: ' + cond); db.query(sql, cond, function(err, rows, fiels) { if(err) return next(err); res.render('simpleJsonResult', {result: rows}); }); }; Using MySQL connector - Query 2