SlideShare a Scribd company logo
Lucas Jellema, 31st March 2016
Introducing Node.js
1
Overview
• Get used to it: JavaScript on the Server
• First steps with Node.js and yes: hello world!
• Some language essentials: functions (and closures)
• Modules and npm
• The Single Thread or: the quest for scalability
• Handling HTTP requests
– static file serving
– serving rich client web applications [such as Oracle JET]
– Implementing REST APIs and mBaaS (and iPaaS)
• Making HTTP calls to external APIs and Services
• Database interaction from Node.js
3
Supporting Resources on GitHub
• https://github.com/lucasjellema/sig-nodejs-amis-2016
4
Popularity Ratings…
5
6
7
JavaScript
in enterprise architecture
Mobile
Client
Browser
Web Tier
Static file
serving
REST
APIs
DBBusiness Tier
Integration
Orchestration
/ BPM
Background
Jobs
ERP
SaaS
External
Service
External
Service
8
Node.js is like a JS-DK –
JavaScript Virtual Machine
Custom
Node.js
app
Custom
Node.js
app Custom
Node.js
app
machine code
9
Brief History of Node.js
• 2009 – unveiled by Ryan Dahl, written on Linux, leveraging Google V8
• 2010
– Initial release of express – the default web application server framework
• 2011
– package manager npm introduced – to publish and share open-source Node.js libraries
and simplify installation, updating and uninstallation of libraries
– Native Windows implementation of Node.js released
• 2011-2015 Many Cloud Platforms supporting Node.js
– Heroku, Joyent, Cloud Foundry, Nodester, NodeJitsu, Microsoft Azure, IBM BlueMix,
Google AppEngine, AWS, …
• 2015
– Oracle releases node-oracledb Database Driver for Node.js
– Various forks brought back together: Node v4.0 including V8 with ES6 features
– Open Source under Governance by the Node.js Foundation under Linux Foundation
– Support for ARM processors
• 2016
– Oracle Application Container Cloud with native support for Node.js applications
– Current release: 5.9.1 (22nd March)
Storage
Compute
DBaaS
Storage
Compute
DBaaS
JCS
SOA
CS
Storage
Compute
ACC
ICS
MCS
DCS
PCS
Compute
ACC
IoT
CS
OSN Sites
CS
mediator-proxy
11
Node.js one of the viable platforms within
new Oracle Micro Services platform
12
Hello World
// my first Node.js program
console.log("Hello World!");
13
Hello World – using a function
function greeting() {
console.log("Hello World!");
}
greeting();
14
Hello World – read
commandline arguments
function greeting(greetedPerson) {
console.log("Hello "+ greetedPerson + "!");
}
// assume command line: node hello-world-3.js someName
var greetee = process.argv[2];
greeting(greetee);
15
Hello World – pass around a
function reference
var g = function greeting(greetedPerson) {
console.log("Hello "+ greetedPerson + "!");
}
var greetee = process.argv[2];
g(greetee);
16
Hello World – have one function
execute [a reference to ] another
var g = function greeting(greetedPerson) {
console.log("Hello "+ greetedPerson + "!");
}
var greetee = process.argv[2];
function reception( greetFunction, greetee) {
greetFunction(greetee); // execute the passed in function
}
reception(g, greetee);
17
Hello World – callback functions
and time outs – no state yet
// callback functions used with timeout
var g = function (greetedPerson) {
console.log("Hello "+ greetedPerson + "!");
}
var r = function ( greetFunction, greetee) {
greetFunction(greetee);
}
for (var i=2;i<process.argv.length;i++) {
setTimeout( r(g, process.argv[i]), i*1500);
}
console.log('The Main Program Flow is Done!');
18
Hello World – closures with state
executed on time out
var g = function (greetedPerson) {
console.log("Hello "+ greetedPerson + "!");
}
function getGreeter ( greetee, greetFunction) {
var toGreet = greetee;
console.log('I will greet '+ greetee + ' in a little while');
return function () { greetFunction(toGreet)}; // the closure
}
for (var i=2;i<process.argv.length;i++) {
setTimeout( getGreeter( process.argv[i], g), i*1500);
}
console.log('The Main Program Flow is Done!');
19
Modules
• Node programs can be organized in modules
• A module is file that exports a scope that may contain (public) functions
and shared objects
• Modules are ‘imported’ through the require function
– Add a line such as var localRef = require(‘moduleName’); in a file to get access at
runtime to all the goodies from the module
• Node ships with a set of core modules that can be required into any
program – without additional installation or configuration; for example:
– fs: file system operations
– path: string transformations around file system operations
– os: access to some operating systems details
– util: utility functions, for example util.log to log messages to console with timestamp
– http: for HTTP protocol based network operations
20
File manipulation from Node.js
- using core module fs
//write a file with all command line arguments on separate lines
var fs = require('fs')
, util = require('util');
process.argv.slice(2).forEach(function (val) {
fs.appendFileSync("./output.txt", val + "n");
});
util.log('The Main Program Flow is Done!');
21
Hello World –
using core module util
var util = require('util');
var g = function (greetedPerson) {
util.log(util.format('Hello %s!', greetedPerson));
}
function getGreeter ( greetee, greetFunction) {
var toGreet = greetee;
util.log( util.format('I will greet %s in a little while', toGreet));
return function () { greetFunction(toGreet)};
}
process.argv.slice(2).forEach(function (val, index, array) {
setTimeout( getGreeter(val, g), index*1500);
});
util.log('The Main Program Flow is Done!');
22
Packages
• A package is a bundle of resources that supports development of a node
application
– Design time (test, code analyze, format, browserify, package, …)
– Run time
• A package can contain one or more modules that may or may not be
intended to be ‘required’ into a node application
• Packages are [downloaded and] added to the source folders of a node
application
• Package management can be tricky
– An application can depend on multiple packages
– Packages can depend on multiple [versions of] packages themselves
– Gathering and keeping up to date all compatible versions of all required packages is
potentially complex, time consuming and error prone
– Enter: npm
• and package.json – the closest thing to a pom-file
23
Reusing node modules
• “So that's what npm is. It's a way to reuse code from other developers,
and also a way to share your code with them, and it makes it easy to
manage the different versions of code.”
• www.npmjs.org
24
npm
• Bring in a package to your current application
– npm install <package name>
The package is downloaded and installed in folder node_modules
• Create a new application with a neat description
– npm init
This will create a package.json file that
describes the [Node.js] application and its dependencies
• Use
– npm install <package name> --save
To have dependencies on the package added to the package,json file
– npm install
To have all packages listed in package.json installed or updated into the
node_modules folder
25
Node.js can handle incoming
HTTP requests
• Similar to a Java Servlet or PHP page, a Node.js application can contain
logic to interpret and respond to an HTTP request
Browser
Web Tier
Static file
serving
REST
APIs
http request
Any other
HTTP
client
26
Core Modules for (inbound & outbound)
networking: http, https, net, dgram
• No separate installation required (included with core Node.js)
• Handle incoming request and/or make outbound request
• Handle URL (path, query parameters, post payload or Form encoding or
file upload)
• Handle headers, encoding, compression, …
Web Tier
http(s) request http(s) request
27
Simplest form of HTTP handling
// invoke from browser or using curl: curl http://127.0.0.1:3000
var http = require('http');
var server = http.createServer(function handleRequest(req, res) {
res.write('Hello World!');
res.end();
}).listen(3000);
console.log('server running on port 3000');
Web Tierhttp(s) request
28
Interpret request and respond
appropriately
// invoke: curl http://127.0.0.1:3000/do/me/a/resource?name=Lex
var http = require('http')
, url = require('url') ;
var server = http.createServer(function handleRequest(req, res) {
console.log('URL '+ req.url);
var queryObject = url.parse(req.url,true).query;
var name = queryObject.name;
console.log('path: '+url.parse(req.url).pathname);
console.log('queryObject: '+JSON.stringify(queryObject));
res.write('Hello '+ name + '!');
res.end();
}).listen(3000);
Web Tierhttp(s) request
29
Interpret request and respond
appropriately
// invoke: curl http://127.0.0.1:3000/do/me/a/resource?name=Lex
var http = require('http')
, url = require('url') ;
var server = http.createServer(function handleRequest(req, res) {
console.log('URL '+ req.url);
var queryObject = url.parse(req.url,true).query;
var name = queryObject.name;
console.log('path: '+url.parse(req.url).pathname);
console.log('queryObject: '+JSON.stringify(queryObject));
res.write('Hello '+ name + '!');
res.end();
}).listen(3000);
Web Tierhttp(s) request
30
Static File Serving
// serve static file: /public/index.html
var http = require('http')
, fs= require('fs');
var server = http.createServer(function handleRequest(req, res) {
res.writeHead(200, { 'content-type': 'text/html' });
fs.createReadStream('./public/index.html').pipe(res);
}).listen(3000);
console.log('server running on port 3000');
Web Tierhttp(s) request
Local file
system
index.html
31
Remote Resource Serving –
http in and http out
var http = require('http');
var options = {
host: 'www.un.org', path: '/en/universal-declaration-human-rights/' };
var server = http.createServer(function handleRequest(req, res) {
res.writeHead(200, { 'content-type': 'text/html' });
http.get(options, function handleRemoteResponse(resp) {
var body="";
resp.on("data", function(chunk) { //response returned in chunks
body = body+chunk;
});
resp.on("end", function() { //when response is complete, pass it on
res.end(body);
});
}).on('error', function(e) {
console.log("Got error: "+ e.message);
});
}).listen(3000); Remote
Website
http
request
32
Express web application
framework
• Fast, unopinionated, minimalist web framework for Node.js
• Framework on top of core Node.js top facilitate incoming HTTP requests
– “Express provides a thin layer of fundamental web application features, without
obscuring Node.js features that you know and love.”
• Convenient for
– Web Server for static files
– API implementation (REST)
– Any incoming HTTP request handling
• Express is distributed as npm package
– npm install express
33
Express - Simplest form of HTTP
handling
// invoke from browser or using curl: curl http://127.0.0.1:3000
var express = require('express')
, http = require('http');
var app = express()
.use(function (req, res, next) {
res.end('Hello World!');
});
// Create HTTP server with Express app as the request listener
http.createServer(app)
.listen(3000);
Web Tierhttp(s) request
34
Express – Even simpler form of HTTP
handling (or at least simpler code)
// invoke from browser or using curl: curl http://127.0.0.1:3000
var express = require('express');
express().use(function (req, res, next) {
res.end('Hello World!');
}).listen(3000);
console.log('server running on port 3000');
Web Tierhttp(s) request
35
Static File Serving
// static file server for all resources in public and below
// will server public/index.html when invoked at http://127.0.0.1:3000
var express = require('express'); //npm install express
express().use(express.static(__dirname + '/public'))
.listen(3000);
console.log('server running on port 3000');
Integration
Tierhttp(s) request
Local file
system
index.html
image.jpg
some-pdf.pdf
36
Oracle JET on Node.js
• Oracle JET is a rich client web application
• All the action is on the client
• Role of Node.js: serve the JET application with all its required resources
– All static HTML, CSS and JS files
app
.js
37
Oracle JET on Node.js
• Oracle JET is a rich client web application
• All the action is on the client
• Role of Node.js: serve the JET application with all its required resources
– All static HTML, CSS and JS files
• Additionally: Node.js can provide back end APIs and proxy that JET
application leverages
REST
API
app
.js
38
Handling Form Submit and other
HTTP POST requests
// static file server for all resources in public and below
// AND handle forms submission to path /forms/...
var express = require('express'); //npm install express
var bodyParser = require('body-parser'); // npm install body-parser
var app = express()
.use(bodyParser.urlencoded({ extended: true}))
.post('/forms/*', function (req, res) { //process
console.log(JSON.stringify(req.body));
res.end('Thank you '+ req.body.firstname
+' '+req.body.lastname);
})
.use(express.static(__dirname + '/public'))
.listen(3000);
Integration
Tier
POST request Local
file
system
39
Handling REST GET requests
var express = require('express'), fs = require('fs');
var departments= JSON.parse(fs.readFileSync('departments.json', 'utf8'));
var app = express()
.get('/departments/:departmentId', function (req, res) {
var department = getDepartment(req.params['departmentId']);
console.log(JSON.stringify(department));
res.send( department);
})
.get('/departments', function (req, res) {
res.send( departments);
})
.use(express.static(__dirname + '/public'))
.listen(3000);
function getDepartment(depIdentifier) {
for (var i=0; i< departments.length; i++) {
if (departments[i].DEPARTMENT_ID == deptIdentifier) {
return departments[i];
}//if
}//for
}// getDepartment
Integration
Tier
GET request
Local file
system
departments
.json
40
Handling REST GET & Form
POST requests
var express = require('express'),bodyParser = require('body-parser')
, fs = require('fs');
var app = express()
.use(bodyParser.urlencoded({ extended: true}))
.post('/forms/department', function (req, res) { //process
console.log(JSON.stringify(req.body));
departments.push( {"DEPARTMENT_ID":req.body.departmentId
,"DEPARTMENT_NAME":req.body.departmentName});
res.end('Thank you for the new department '+
req.body.departmentId+" "+req.body.departmentName);
})
.get('/departments/:departmentId', function (req, res) {
…
.listen(3000);
Integration
Tier
GET request
Local file
system
departments
.json
Form Submit
41
Serve Department details –
retrieved from external REST API
var express = require('express'),bodyParser = require('body-parser')
, fs = require('fs'), https = require('https');
var app = express()
.get('/departmentdetails/:departmentId', function (req, res) {
var departmentId = req.params['departmentId'];
var department = getDepartment(departmentId);
// get employee details for department from remote API
https.get({ host: 'data-api-oraclecloud.com', port: 443,
path: '/departments/'+departmentId, method: 'GET'
}, function handleRemoteResponse(resp) {
var body="";
resp.on("data", function(chunk) {body += chunk; });
resp.on("end", function() {
department.employees = JSON.parse(body);
res.send(department); });
});
})
.listen(3000);
Integration
Tier
GET request
Local file
system
departments
.json
REST
API
42
And now for a real USP
43
Access speed for data
retrieved from various sources
Source: Beginning Node.js - by Basarat Ali Syed Apress, released: December 2014
44
Threads in web application
handling HTTP-requests
Source: Beginning Node.js - by Basarat Ali Syed Apress, released: December 2014
45
Ready-to-run Threads in web
application handling HTTP-requests
Source: Beginning Node.js - by Basarat Ali Syed Apress, released: December 2014
46
cash
registers
desk to collect
large pieces
Warehouse
Exit
waiting area
shopping area
Only a single desk to handle all
customers who want to have stuff
from the warehouse brought to them
– compare with over a dozen cash
registers
47
Single Thread model in Node.js
48
Single Thread
• No synchronous calls or blocking waits are done on the thread
– intensive work too is pushed to another process
• After the question is asked, the thread moves
• When a response arrives – as an asynchronous event – the callback
function is given the opportuniy to act on it
– Again, as quickly as possible, not tying up shared resources!
49
50
The single thread way: Nginx
51
The single thread way: Nginx
52
Asynchronously assembling
the HTTP response
• Receive HTTP request
– Possibly leverage cookie to re-establish state/context
• Set work in motion to collect data (remote API call, DB call) and register
callback – with original request scope
• Stop processing, vanish, release resources
• When callback is invoked, use response to construct the response
– Complete and send the response
Callback == Closure
(function to execute with
context to execute in)
53
Artist API
• Provide rich JSON message for an artist
• External APIs invoked: Spotify and Echonest
• External calls are made in parallel
– Waiting is done in parallel
– Constructing the response is done when both responses are in
Integration
Tier
GET request
for some artist
54
async
• The node module async is a utility module which provides straight-
forward, powerful functions for working with asynchronous JavaScript.
• Available for server side Node.js and for use in the browser client
• Program easily with asynchronous interactions
– Coordinate parallel or sequential calls and deal with errors
• Example operations:
– Map
– Reduce
– Filter
– Waterfall
– Parallel
– ForEachOf
– Series
55
async – execute in parallel
var async = require(‘async')
, fs = require(‘fs');
var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
var configs = {};
async.forEachOf(obj, function (value, key, callback) {
fs.readFile(__dirname + value, "utf8", function (err, data) {
if (err) return callback(err);
try {
configs[key] = JSON.parse(data);
} catch (e) {
return callback(e);
}
callback();
});
}, function (err) { // when all parallel actions are done – do something
if (err) { console.error(err.message); return;}
// configs is now a map of JSON data
doSomethingWith(configs);
})
For each property
in the object…
… execute this
function
Asynchronously
read the file .. and when done,
call this function
Notify forEachOf of the
completion of this branch
When all parallel branches under
forEachOf are done, do this function
56
node-oracledb database driver
• The node-oracledb driver connects to Oracle Database
for fast and functional applications. It is an open source
project with Apache 2.0 license.
• It is maintained as an NPM package by Oracle and is under active
development.
• https://github.com/oracle/node-oracledb or
npm install node-oracledb
• Note: the Oracle Application Container Cloud preloads this driver to any
instance of a Node.js container – ready to connect to DBaaS or on
premises database
• Support for SQL and PL/SQL, Transaction Management, CLOBs and
BLOBs, Ref Cursors, Types and Collections, authentication, …
– Leveraging OCI Oracle (Fat) Client Libraries
57
Connect to Oracle Database
from node application …
var oracledb = require('oracledb');
var dbConfig = require('./dbconfig.js');
oracledb.getConnection(
{
user : dbConfig.user,
password : dbConfig.password,
connectString : dbConfig.connectString
},
function(err, connection)
{
if (err) {
console.error(err.message);
return;
}
connection.execute(
...
Integration
Tier
58
… and perform SQL or PL/SQL
...
connection.execute(
"SELECT department_id, department_name " +
"FROM departments " +
"WHERE department_id = :did",
[180],
function(err, result)
{
if (err) {
console.error(err.message);
doRelease(connection);
return;
}
console.log(result.metaData);
console.log(result.rows);
doRelease(connection);
});
});
function doRelease(connection)
{ connection.release( function(err) {…});}
Integration
Tier
59
Oracle Application Container Cloud
for Node.js with DB driver
Application Container Cloud
Docker
Node.js ContainerREST clients
data-api
RES
T
API
DBaaS
Service
Binding
oracledb
DB driver
MyJCSDB
demos PDB1
H
R
60
Next steps and beyond
• API Development
• Explore npm packages – 10Ks of them
– For SOAP, XML, IMDB, Dictionary, Geography, Text-to-Speech, Loopback mBaaS …
• Advanced topics: Web Sockets , security, scaling, H/A, state in a stateless
world, queuing and scheduling ‘background jobs’
• Creating your own modules and NPM packages
– Contribute to existing packages
• Promises – for an escape from callback hell
• IDEs – Visual Studio Code, WebStorm, NetBeans
• Debugging
• Testing
• Deployment
• Rethink mBaaS & iPaaS
61

More Related Content

PPTX
Fontys Lecture - The Evolution of the Oracle Database 2016
PPTX
Soaring through the Clouds - Oracle Fusion Middleware Partner Forum 2016
PPTX
Oracle OpenWorld 2016 Review - High Level Overview of major themes and grand ...
PPT
Introduction to Apache CloudStack by David Nalley
PPTX
Build public private cloud using openstack
PPTX
Brk2051 sql server on linux and docker
PPTX
Le novità di sql server 2019
PDF
Cloud Architect Alliance #15: Openstack
Fontys Lecture - The Evolution of the Oracle Database 2016
Soaring through the Clouds - Oracle Fusion Middleware Partner Forum 2016
Oracle OpenWorld 2016 Review - High Level Overview of major themes and grand ...
Introduction to Apache CloudStack by David Nalley
Build public private cloud using openstack
Brk2051 sql server on linux and docker
Le novità di sql server 2019
Cloud Architect Alliance #15: Openstack

What's hot (20)

PDF
Java One 2017: Open Source Big Data in the Cloud: Hadoop, M/R, Hive, Spark an...
PPTX
SQL Server 2017 on Linux Introduction
PDF
It's a wrap - closing keynote for nlOUG Tech Experience 2017 (16th June, The ...
PDF
Serverless / FaaS / Lambda and how it relates to Microservices
PDF
Oracle Java Cloud Service JCS (and WebLogic 12c) - What you Should Know
PDF
Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...
PDF
Migrating and Running DBs on Amazon RDS for Oracle
PPTX
MariaDB Galera Cluster
PPTX
Experience SQL Server 2017: The Modern Data Platform
PDF
MySQL Performance - Best practices
PPTX
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
PDF
Storing and processing data with the wso2 platform
KEY
Near-realtime analytics with Kafka and HBase
PPTX
Review Oracle OpenWorld 2015 - Overview, Main themes, Announcements and Future
PPTX
Performance out
PPTX
2017 OWASP SanFran March Meetup - Hacking SQL Server on Scale with PowerShell
PDF
Azure Boot Camp 21.04.2018 SQL Server in Azure Iaas PaaS on-prem Lars Platzdasch
PPTX
SQL Server vNext on Linux
PDF
Oracle CODE 2017 San Francisco: Docker on Raspi Swarm to OCCS
PPT
ActiveMQ 5.9.x new features
Java One 2017: Open Source Big Data in the Cloud: Hadoop, M/R, Hive, Spark an...
SQL Server 2017 on Linux Introduction
It's a wrap - closing keynote for nlOUG Tech Experience 2017 (16th June, The ...
Serverless / FaaS / Lambda and how it relates to Microservices
Oracle Java Cloud Service JCS (and WebLogic 12c) - What you Should Know
Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...
Migrating and Running DBs on Amazon RDS for Oracle
MariaDB Galera Cluster
Experience SQL Server 2017: The Modern Data Platform
MySQL Performance - Best practices
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
Storing and processing data with the wso2 platform
Near-realtime analytics with Kafka and HBase
Review Oracle OpenWorld 2015 - Overview, Main themes, Announcements and Future
Performance out
2017 OWASP SanFran March Meetup - Hacking SQL Server on Scale with PowerShell
Azure Boot Camp 21.04.2018 SQL Server in Azure Iaas PaaS on-prem Lars Platzdasch
SQL Server vNext on Linux
Oracle CODE 2017 San Francisco: Docker on Raspi Swarm to OCCS
ActiveMQ 5.9.x new features
Ad

Viewers also liked (20)

PPTX
Oracle Database 12c - Introducing SQL Pattern Recognition through MATCH_RECOG...
PPTX
What is the Oracle PaaS Cloud for Developers (Oracle Cloud Day, The Netherlan...
PPTX
Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...
PPTX
Handson Oracle Management Cloud with Application Performance Monitoring and L...
PPTX
The True State of the Oracle Public Cloud - Dutch Oracle Architects Platform ...
PPTX
Systems on the edge - your stepping stones into Oracle Public PaaS Cloud - AM...
PPTX
Introducing Oracle Real-Time Integration Business Insight
PPTX
Ranges, ranges everywhere (Oracle SQL)
PPTX
Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...
PPSX
Row Pattern Matching in Oracle Database 12c
PDF
Introducing Kafka's Streams API
PPTX
Comparing 30 MongoDB operations with Oracle SQL statements
PDF
Pra latihan
PDF
Use Cases of Row Pattern Matching in Oracle 12c
PPTX
Row patternmatching12ctech14
PDF
ODTUG Technical Journal - The Reusability Test - Fusion Column July 2010
PDF
Forms2Future in action for SaaS provider Connexys
PPTX
Slides for Oracle OpenWorld 2015 Tuesday Keynote by Thomas Kurian - Software ...
PPTX
Row Pattern Matching 12c MATCH_RECOGNIZE OOW14
PPTX
NodeJS - Server Side JS
Oracle Database 12c - Introducing SQL Pattern Recognition through MATCH_RECOG...
What is the Oracle PaaS Cloud for Developers (Oracle Cloud Day, The Netherlan...
Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...
Handson Oracle Management Cloud with Application Performance Monitoring and L...
The True State of the Oracle Public Cloud - Dutch Oracle Architects Platform ...
Systems on the edge - your stepping stones into Oracle Public PaaS Cloud - AM...
Introducing Oracle Real-Time Integration Business Insight
Ranges, ranges everywhere (Oracle SQL)
Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...
Row Pattern Matching in Oracle Database 12c
Introducing Kafka's Streams API
Comparing 30 MongoDB operations with Oracle SQL statements
Pra latihan
Use Cases of Row Pattern Matching in Oracle 12c
Row patternmatching12ctech14
ODTUG Technical Journal - The Reusability Test - Fusion Column July 2010
Forms2Future in action for SaaS provider Connexys
Slides for Oracle OpenWorld 2015 Tuesday Keynote by Thomas Kurian - Software ...
Row Pattern Matching 12c MATCH_RECOGNIZE OOW14
NodeJS - Server Side JS
Ad

Similar to Introducing Node.js in an Oracle technology environment (including hands-on) (20)

PPTX
Introduction to Node (15th May 2017)
PPT
nodejs_at_a_glance.ppt
PPT
nodejs_at_a_glance, understanding java script
PDF
Node.js 101 with Rami Sayar
PPTX
Node.js Workshop - Sela SDP 2015
PDF
Introduction to Node.js: What, why and how?
PDF
FITC - Node.js 101
PDF
PDF
Nodejs a-practical-introduction-oredev
PDF
Kubernetes for the PHP developer
PPT
Node js beginner
PDF
Introduction to node js - From "hello world" to deploying on azure
PPTX
Introduction to Node.js
PDF
Basic Understanding and Implement of Node.js
DOCX
unit 2 of Full stack web development subject
PPTX
Introduction to node.js GDD
PPTX
introduction to node.js
PPTX
Node.js: The What, The How and The When
KEY
Node.js - A practical introduction (v2)
Introduction to Node (15th May 2017)
nodejs_at_a_glance.ppt
nodejs_at_a_glance, understanding java script
Node.js 101 with Rami Sayar
Node.js Workshop - Sela SDP 2015
Introduction to Node.js: What, why and how?
FITC - Node.js 101
Nodejs a-practical-introduction-oredev
Kubernetes for the PHP developer
Node js beginner
Introduction to node js - From "hello world" to deploying on azure
Introduction to Node.js
Basic Understanding and Implement of Node.js
unit 2 of Full stack web development subject
Introduction to node.js GDD
introduction to node.js
Node.js: The What, The How and The When
Node.js - A practical introduction (v2)

More from Lucas Jellema (20)

PPTX
Introduction to web application development with Vue (for absolute beginners)...
PPTX
Making the Shift Left - Bringing Ops to Dev before bringing applications to p...
PPTX
Lightweight coding in powerful Cloud Development Environments (DigitalXchange...
PPTX
Apache Superset - open source data exploration and visualization (Conclusion ...
PPTX
CONNECTING THE REAL WORLD TO ENTERPRISE IT – HOW IoT DRIVES OUR ENERGY TRANSI...
PPTX
Help me move away from Oracle - or not?! (Oracle Community Tour EMEA - LVOUG...
PPTX
Op je vingers tellen... tot 1000!
PPTX
IoT - from prototype to enterprise platform (DigitalXchange 2022)
PPTX
Who Wants to Become an IT Architect-A Look at the Bigger Picture - DigitalXch...
PPTX
Steampipe - use SQL to retrieve data from cloud, platforms and files (Code Ca...
PPTX
Automation of Software Engineering with OCI DevOps Build and Deployment Pipel...
PPTX
Introducing Dapr.io - the open source personal assistant to microservices and...
PPTX
How and Why you can and should Participate in Open Source Projects (AMIS, Sof...
PPTX
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
PPTX
Microservices, Node, Dapr and more - Part One (Fontys Hogeschool, Spring 2022)
PPTX
6Reinventing Oracle Systems in a Cloudy World (RMOUG Trainingdays, February 2...
PPTX
Help me move away from Oracle! (RMOUG Training Days 2022, February 2022)
PPTX
Tech Talks 101 - DevOps (jan 2022)
PPTX
Conclusion Code Cafe - Microcks for Mocking and Testing Async APIs (January 2...
PPTX
Cloud Native Application Development - build fast, low TCO, scalable & agile ...
Introduction to web application development with Vue (for absolute beginners)...
Making the Shift Left - Bringing Ops to Dev before bringing applications to p...
Lightweight coding in powerful Cloud Development Environments (DigitalXchange...
Apache Superset - open source data exploration and visualization (Conclusion ...
CONNECTING THE REAL WORLD TO ENTERPRISE IT – HOW IoT DRIVES OUR ENERGY TRANSI...
Help me move away from Oracle - or not?! (Oracle Community Tour EMEA - LVOUG...
Op je vingers tellen... tot 1000!
IoT - from prototype to enterprise platform (DigitalXchange 2022)
Who Wants to Become an IT Architect-A Look at the Bigger Picture - DigitalXch...
Steampipe - use SQL to retrieve data from cloud, platforms and files (Code Ca...
Automation of Software Engineering with OCI DevOps Build and Deployment Pipel...
Introducing Dapr.io - the open source personal assistant to microservices and...
How and Why you can and should Participate in Open Source Projects (AMIS, Sof...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Node, Dapr and more - Part One (Fontys Hogeschool, Spring 2022)
6Reinventing Oracle Systems in a Cloudy World (RMOUG Trainingdays, February 2...
Help me move away from Oracle! (RMOUG Training Days 2022, February 2022)
Tech Talks 101 - DevOps (jan 2022)
Conclusion Code Cafe - Microcks for Mocking and Testing Async APIs (January 2...
Cloud Native Application Development - build fast, low TCO, scalable & agile ...

Recently uploaded (20)

PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
history of c programming in notes for students .pptx
PDF
top salesforce developer skills in 2025.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Transform Your Business with a Software ERP System
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
How Creative Agencies Leverage Project Management Software.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
history of c programming in notes for students .pptx
top salesforce developer skills in 2025.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Design an Analysis of Algorithms I-SECS-1021-03
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
How to Choose the Right IT Partner for Your Business in Malaysia
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Understanding Forklifts - TECH EHS Solution
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
VVF-Customer-Presentation2025-Ver1.9.pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
CHAPTER 2 - PM Management and IT Context
Odoo POS Development Services by CandidRoot Solutions
Transform Your Business with a Software ERP System
ManageIQ - Sprint 268 Review - Slide Deck
How Creative Agencies Leverage Project Management Software.pdf

Introducing Node.js in an Oracle technology environment (including hands-on)

  • 1. Lucas Jellema, 31st March 2016 Introducing Node.js 1
  • 2. Overview • Get used to it: JavaScript on the Server • First steps with Node.js and yes: hello world! • Some language essentials: functions (and closures) • Modules and npm • The Single Thread or: the quest for scalability • Handling HTTP requests – static file serving – serving rich client web applications [such as Oracle JET] – Implementing REST APIs and mBaaS (and iPaaS) • Making HTTP calls to external APIs and Services • Database interaction from Node.js
  • 3. 3 Supporting Resources on GitHub • https://github.com/lucasjellema/sig-nodejs-amis-2016
  • 5. 5
  • 6. 6
  • 7. 7 JavaScript in enterprise architecture Mobile Client Browser Web Tier Static file serving REST APIs DBBusiness Tier Integration Orchestration / BPM Background Jobs ERP SaaS External Service External Service
  • 8. 8 Node.js is like a JS-DK – JavaScript Virtual Machine Custom Node.js app Custom Node.js app Custom Node.js app machine code
  • 9. 9 Brief History of Node.js • 2009 – unveiled by Ryan Dahl, written on Linux, leveraging Google V8 • 2010 – Initial release of express – the default web application server framework • 2011 – package manager npm introduced – to publish and share open-source Node.js libraries and simplify installation, updating and uninstallation of libraries – Native Windows implementation of Node.js released • 2011-2015 Many Cloud Platforms supporting Node.js – Heroku, Joyent, Cloud Foundry, Nodester, NodeJitsu, Microsoft Azure, IBM BlueMix, Google AppEngine, AWS, … • 2015 – Oracle releases node-oracledb Database Driver for Node.js – Various forks brought back together: Node v4.0 including V8 with ES6 features – Open Source under Governance by the Node.js Foundation under Linux Foundation – Support for ARM processors • 2016 – Oracle Application Container Cloud with native support for Node.js applications – Current release: 5.9.1 (22nd March)
  • 11. 11 Node.js one of the viable platforms within new Oracle Micro Services platform
  • 12. 12 Hello World // my first Node.js program console.log("Hello World!");
  • 13. 13 Hello World – using a function function greeting() { console.log("Hello World!"); } greeting();
  • 14. 14 Hello World – read commandline arguments function greeting(greetedPerson) { console.log("Hello "+ greetedPerson + "!"); } // assume command line: node hello-world-3.js someName var greetee = process.argv[2]; greeting(greetee);
  • 15. 15 Hello World – pass around a function reference var g = function greeting(greetedPerson) { console.log("Hello "+ greetedPerson + "!"); } var greetee = process.argv[2]; g(greetee);
  • 16. 16 Hello World – have one function execute [a reference to ] another var g = function greeting(greetedPerson) { console.log("Hello "+ greetedPerson + "!"); } var greetee = process.argv[2]; function reception( greetFunction, greetee) { greetFunction(greetee); // execute the passed in function } reception(g, greetee);
  • 17. 17 Hello World – callback functions and time outs – no state yet // callback functions used with timeout var g = function (greetedPerson) { console.log("Hello "+ greetedPerson + "!"); } var r = function ( greetFunction, greetee) { greetFunction(greetee); } for (var i=2;i<process.argv.length;i++) { setTimeout( r(g, process.argv[i]), i*1500); } console.log('The Main Program Flow is Done!');
  • 18. 18 Hello World – closures with state executed on time out var g = function (greetedPerson) { console.log("Hello "+ greetedPerson + "!"); } function getGreeter ( greetee, greetFunction) { var toGreet = greetee; console.log('I will greet '+ greetee + ' in a little while'); return function () { greetFunction(toGreet)}; // the closure } for (var i=2;i<process.argv.length;i++) { setTimeout( getGreeter( process.argv[i], g), i*1500); } console.log('The Main Program Flow is Done!');
  • 19. 19 Modules • Node programs can be organized in modules • A module is file that exports a scope that may contain (public) functions and shared objects • Modules are ‘imported’ through the require function – Add a line such as var localRef = require(‘moduleName’); in a file to get access at runtime to all the goodies from the module • Node ships with a set of core modules that can be required into any program – without additional installation or configuration; for example: – fs: file system operations – path: string transformations around file system operations – os: access to some operating systems details – util: utility functions, for example util.log to log messages to console with timestamp – http: for HTTP protocol based network operations
  • 20. 20 File manipulation from Node.js - using core module fs //write a file with all command line arguments on separate lines var fs = require('fs') , util = require('util'); process.argv.slice(2).forEach(function (val) { fs.appendFileSync("./output.txt", val + "n"); }); util.log('The Main Program Flow is Done!');
  • 21. 21 Hello World – using core module util var util = require('util'); var g = function (greetedPerson) { util.log(util.format('Hello %s!', greetedPerson)); } function getGreeter ( greetee, greetFunction) { var toGreet = greetee; util.log( util.format('I will greet %s in a little while', toGreet)); return function () { greetFunction(toGreet)}; } process.argv.slice(2).forEach(function (val, index, array) { setTimeout( getGreeter(val, g), index*1500); }); util.log('The Main Program Flow is Done!');
  • 22. 22 Packages • A package is a bundle of resources that supports development of a node application – Design time (test, code analyze, format, browserify, package, …) – Run time • A package can contain one or more modules that may or may not be intended to be ‘required’ into a node application • Packages are [downloaded and] added to the source folders of a node application • Package management can be tricky – An application can depend on multiple packages – Packages can depend on multiple [versions of] packages themselves – Gathering and keeping up to date all compatible versions of all required packages is potentially complex, time consuming and error prone – Enter: npm • and package.json – the closest thing to a pom-file
  • 23. 23 Reusing node modules • “So that's what npm is. It's a way to reuse code from other developers, and also a way to share your code with them, and it makes it easy to manage the different versions of code.” • www.npmjs.org
  • 24. 24 npm • Bring in a package to your current application – npm install <package name> The package is downloaded and installed in folder node_modules • Create a new application with a neat description – npm init This will create a package.json file that describes the [Node.js] application and its dependencies • Use – npm install <package name> --save To have dependencies on the package added to the package,json file – npm install To have all packages listed in package.json installed or updated into the node_modules folder
  • 25. 25 Node.js can handle incoming HTTP requests • Similar to a Java Servlet or PHP page, a Node.js application can contain logic to interpret and respond to an HTTP request Browser Web Tier Static file serving REST APIs http request Any other HTTP client
  • 26. 26 Core Modules for (inbound & outbound) networking: http, https, net, dgram • No separate installation required (included with core Node.js) • Handle incoming request and/or make outbound request • Handle URL (path, query parameters, post payload or Form encoding or file upload) • Handle headers, encoding, compression, … Web Tier http(s) request http(s) request
  • 27. 27 Simplest form of HTTP handling // invoke from browser or using curl: curl http://127.0.0.1:3000 var http = require('http'); var server = http.createServer(function handleRequest(req, res) { res.write('Hello World!'); res.end(); }).listen(3000); console.log('server running on port 3000'); Web Tierhttp(s) request
  • 28. 28 Interpret request and respond appropriately // invoke: curl http://127.0.0.1:3000/do/me/a/resource?name=Lex var http = require('http') , url = require('url') ; var server = http.createServer(function handleRequest(req, res) { console.log('URL '+ req.url); var queryObject = url.parse(req.url,true).query; var name = queryObject.name; console.log('path: '+url.parse(req.url).pathname); console.log('queryObject: '+JSON.stringify(queryObject)); res.write('Hello '+ name + '!'); res.end(); }).listen(3000); Web Tierhttp(s) request
  • 29. 29 Interpret request and respond appropriately // invoke: curl http://127.0.0.1:3000/do/me/a/resource?name=Lex var http = require('http') , url = require('url') ; var server = http.createServer(function handleRequest(req, res) { console.log('URL '+ req.url); var queryObject = url.parse(req.url,true).query; var name = queryObject.name; console.log('path: '+url.parse(req.url).pathname); console.log('queryObject: '+JSON.stringify(queryObject)); res.write('Hello '+ name + '!'); res.end(); }).listen(3000); Web Tierhttp(s) request
  • 30. 30 Static File Serving // serve static file: /public/index.html var http = require('http') , fs= require('fs'); var server = http.createServer(function handleRequest(req, res) { res.writeHead(200, { 'content-type': 'text/html' }); fs.createReadStream('./public/index.html').pipe(res); }).listen(3000); console.log('server running on port 3000'); Web Tierhttp(s) request Local file system index.html
  • 31. 31 Remote Resource Serving – http in and http out var http = require('http'); var options = { host: 'www.un.org', path: '/en/universal-declaration-human-rights/' }; var server = http.createServer(function handleRequest(req, res) { res.writeHead(200, { 'content-type': 'text/html' }); http.get(options, function handleRemoteResponse(resp) { var body=""; resp.on("data", function(chunk) { //response returned in chunks body = body+chunk; }); resp.on("end", function() { //when response is complete, pass it on res.end(body); }); }).on('error', function(e) { console.log("Got error: "+ e.message); }); }).listen(3000); Remote Website http request
  • 32. 32 Express web application framework • Fast, unopinionated, minimalist web framework for Node.js • Framework on top of core Node.js top facilitate incoming HTTP requests – “Express provides a thin layer of fundamental web application features, without obscuring Node.js features that you know and love.” • Convenient for – Web Server for static files – API implementation (REST) – Any incoming HTTP request handling • Express is distributed as npm package – npm install express
  • 33. 33 Express - Simplest form of HTTP handling // invoke from browser or using curl: curl http://127.0.0.1:3000 var express = require('express') , http = require('http'); var app = express() .use(function (req, res, next) { res.end('Hello World!'); }); // Create HTTP server with Express app as the request listener http.createServer(app) .listen(3000); Web Tierhttp(s) request
  • 34. 34 Express – Even simpler form of HTTP handling (or at least simpler code) // invoke from browser or using curl: curl http://127.0.0.1:3000 var express = require('express'); express().use(function (req, res, next) { res.end('Hello World!'); }).listen(3000); console.log('server running on port 3000'); Web Tierhttp(s) request
  • 35. 35 Static File Serving // static file server for all resources in public and below // will server public/index.html when invoked at http://127.0.0.1:3000 var express = require('express'); //npm install express express().use(express.static(__dirname + '/public')) .listen(3000); console.log('server running on port 3000'); Integration Tierhttp(s) request Local file system index.html image.jpg some-pdf.pdf
  • 36. 36 Oracle JET on Node.js • Oracle JET is a rich client web application • All the action is on the client • Role of Node.js: serve the JET application with all its required resources – All static HTML, CSS and JS files app .js
  • 37. 37 Oracle JET on Node.js • Oracle JET is a rich client web application • All the action is on the client • Role of Node.js: serve the JET application with all its required resources – All static HTML, CSS and JS files • Additionally: Node.js can provide back end APIs and proxy that JET application leverages REST API app .js
  • 38. 38 Handling Form Submit and other HTTP POST requests // static file server for all resources in public and below // AND handle forms submission to path /forms/... var express = require('express'); //npm install express var bodyParser = require('body-parser'); // npm install body-parser var app = express() .use(bodyParser.urlencoded({ extended: true})) .post('/forms/*', function (req, res) { //process console.log(JSON.stringify(req.body)); res.end('Thank you '+ req.body.firstname +' '+req.body.lastname); }) .use(express.static(__dirname + '/public')) .listen(3000); Integration Tier POST request Local file system
  • 39. 39 Handling REST GET requests var express = require('express'), fs = require('fs'); var departments= JSON.parse(fs.readFileSync('departments.json', 'utf8')); var app = express() .get('/departments/:departmentId', function (req, res) { var department = getDepartment(req.params['departmentId']); console.log(JSON.stringify(department)); res.send( department); }) .get('/departments', function (req, res) { res.send( departments); }) .use(express.static(__dirname + '/public')) .listen(3000); function getDepartment(depIdentifier) { for (var i=0; i< departments.length; i++) { if (departments[i].DEPARTMENT_ID == deptIdentifier) { return departments[i]; }//if }//for }// getDepartment Integration Tier GET request Local file system departments .json
  • 40. 40 Handling REST GET & Form POST requests var express = require('express'),bodyParser = require('body-parser') , fs = require('fs'); var app = express() .use(bodyParser.urlencoded({ extended: true})) .post('/forms/department', function (req, res) { //process console.log(JSON.stringify(req.body)); departments.push( {"DEPARTMENT_ID":req.body.departmentId ,"DEPARTMENT_NAME":req.body.departmentName}); res.end('Thank you for the new department '+ req.body.departmentId+" "+req.body.departmentName); }) .get('/departments/:departmentId', function (req, res) { … .listen(3000); Integration Tier GET request Local file system departments .json Form Submit
  • 41. 41 Serve Department details – retrieved from external REST API var express = require('express'),bodyParser = require('body-parser') , fs = require('fs'), https = require('https'); var app = express() .get('/departmentdetails/:departmentId', function (req, res) { var departmentId = req.params['departmentId']; var department = getDepartment(departmentId); // get employee details for department from remote API https.get({ host: 'data-api-oraclecloud.com', port: 443, path: '/departments/'+departmentId, method: 'GET' }, function handleRemoteResponse(resp) { var body=""; resp.on("data", function(chunk) {body += chunk; }); resp.on("end", function() { department.employees = JSON.parse(body); res.send(department); }); }); }) .listen(3000); Integration Tier GET request Local file system departments .json REST API
  • 42. 42 And now for a real USP
  • 43. 43 Access speed for data retrieved from various sources Source: Beginning Node.js - by Basarat Ali Syed Apress, released: December 2014
  • 44. 44 Threads in web application handling HTTP-requests Source: Beginning Node.js - by Basarat Ali Syed Apress, released: December 2014
  • 45. 45 Ready-to-run Threads in web application handling HTTP-requests Source: Beginning Node.js - by Basarat Ali Syed Apress, released: December 2014
  • 46. 46 cash registers desk to collect large pieces Warehouse Exit waiting area shopping area Only a single desk to handle all customers who want to have stuff from the warehouse brought to them – compare with over a dozen cash registers
  • 48. 48 Single Thread • No synchronous calls or blocking waits are done on the thread – intensive work too is pushed to another process • After the question is asked, the thread moves • When a response arrives – as an asynchronous event – the callback function is given the opportuniy to act on it – Again, as quickly as possible, not tying up shared resources!
  • 49. 49
  • 50. 50 The single thread way: Nginx
  • 51. 51 The single thread way: Nginx
  • 52. 52 Asynchronously assembling the HTTP response • Receive HTTP request – Possibly leverage cookie to re-establish state/context • Set work in motion to collect data (remote API call, DB call) and register callback – with original request scope • Stop processing, vanish, release resources • When callback is invoked, use response to construct the response – Complete and send the response Callback == Closure (function to execute with context to execute in)
  • 53. 53 Artist API • Provide rich JSON message for an artist • External APIs invoked: Spotify and Echonest • External calls are made in parallel – Waiting is done in parallel – Constructing the response is done when both responses are in Integration Tier GET request for some artist
  • 54. 54 async • The node module async is a utility module which provides straight- forward, powerful functions for working with asynchronous JavaScript. • Available for server side Node.js and for use in the browser client • Program easily with asynchronous interactions – Coordinate parallel or sequential calls and deal with errors • Example operations: – Map – Reduce – Filter – Waterfall – Parallel – ForEachOf – Series
  • 55. 55 async – execute in parallel var async = require(‘async') , fs = require(‘fs'); var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; var configs = {}; async.forEachOf(obj, function (value, key, callback) { fs.readFile(__dirname + value, "utf8", function (err, data) { if (err) return callback(err); try { configs[key] = JSON.parse(data); } catch (e) { return callback(e); } callback(); }); }, function (err) { // when all parallel actions are done – do something if (err) { console.error(err.message); return;} // configs is now a map of JSON data doSomethingWith(configs); }) For each property in the object… … execute this function Asynchronously read the file .. and when done, call this function Notify forEachOf of the completion of this branch When all parallel branches under forEachOf are done, do this function
  • 56. 56 node-oracledb database driver • The node-oracledb driver connects to Oracle Database for fast and functional applications. It is an open source project with Apache 2.0 license. • It is maintained as an NPM package by Oracle and is under active development. • https://github.com/oracle/node-oracledb or npm install node-oracledb • Note: the Oracle Application Container Cloud preloads this driver to any instance of a Node.js container – ready to connect to DBaaS or on premises database • Support for SQL and PL/SQL, Transaction Management, CLOBs and BLOBs, Ref Cursors, Types and Collections, authentication, … – Leveraging OCI Oracle (Fat) Client Libraries
  • 57. 57 Connect to Oracle Database from node application … var oracledb = require('oracledb'); var dbConfig = require('./dbconfig.js'); oracledb.getConnection( { user : dbConfig.user, password : dbConfig.password, connectString : dbConfig.connectString }, function(err, connection) { if (err) { console.error(err.message); return; } connection.execute( ... Integration Tier
  • 58. 58 … and perform SQL or PL/SQL ... connection.execute( "SELECT department_id, department_name " + "FROM departments " + "WHERE department_id = :did", [180], function(err, result) { if (err) { console.error(err.message); doRelease(connection); return; } console.log(result.metaData); console.log(result.rows); doRelease(connection); }); }); function doRelease(connection) { connection.release( function(err) {…});} Integration Tier
  • 59. 59 Oracle Application Container Cloud for Node.js with DB driver Application Container Cloud Docker Node.js ContainerREST clients data-api RES T API DBaaS Service Binding oracledb DB driver MyJCSDB demos PDB1 H R
  • 60. 60 Next steps and beyond • API Development • Explore npm packages – 10Ks of them – For SOAP, XML, IMDB, Dictionary, Geography, Text-to-Speech, Loopback mBaaS … • Advanced topics: Web Sockets , security, scaling, H/A, state in a stateless world, queuing and scheduling ‘background jobs’ • Creating your own modules and NPM packages – Contribute to existing packages • Promises – for an escape from callback hell • IDEs – Visual Studio Code, WebStorm, NetBeans • Debugging • Testing • Deployment • Rethink mBaaS & iPaaS
  • 61. 61

Editor's Notes

  • #5: http://stackoverflow.com/research/developer-survey-2015#tech
  • #9: See: http://khan.io/2015/02/25/the-event-loop-and-non-blocking-io-in-node-js/
  • #10: https://github.com/oracle/node-oracledb
  • #37: https://technology.amis.nl/2016/02/07/deploying-an-oracle-jet-application-to-application-container-cloud-and-running-on-node-js/
  • #38: https://technology.amis.nl/2016/02/07/deploying-an-oracle-jet-application-to-application-container-cloud-and-running-on-node-js/
  • #55: https://github.com/caolan/async
  • #57: https://github.com/oracle/node-oracledb http://www.oracle.com/technetwork/database/database-technologies/scripting-languages/node_js/index.html https://technology.amis.nl/2016/02/06/linking-application-container-cloud-to-dbaas-expose-rest-api-from-node-js-application-leveraging-node-oracle-database-driver/ https://oraclejetsample-lucasjellema.apaas.em2.oraclecloud.com/?root=hrm https://data-api-lucasjellema.apaas.em2.oraclecloud.com/departments https://artist-enricher-api-lucasjellema.apaas.em2.oraclecloud.com/artists/get?artist=meat+loaf
  • #61: On websockets: https://devcenter.heroku.com/articles/node-websockets