SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Building
Websites using
Node.ACS
Ricardo Alcocer
Lead Developer Evangelist @ Appcelerator
About me
1. Have been using Titanium since late 2009
2. Former Titanium trainer in the Caribbean and Latin America
3. Currently work as Lead Developer Evangelist
4. Obsessed with cross-platform mobile develoment
5. Love Javascript hacking and technology startups
6. I'm a hacker in constant training
What is Node.ACS
1. Develop and publish node.js apps to the cloud
2. Simple CLI interface and built-in webserver
3. Built-in ACS support
4. Integrated with Titanium Studio
5. It's Javascript but for the server!
Install Node.ACS
Node.ACS runs on top of node.js
Studio installs Node and NPM by default
If you don't, install it from http://nodejs.org/
Run node -v to make sure you have it and then install ACS
node -v
sudo npm install -g acs
Login to Node.ACS
acs login
Create a new Node.ACS
acs new -my_app_name-
Starting your first Node.ACS
acs run
Viewing on the browser
Publishing first app
acs publish
acs publish --force
First app published
MVC Framework
Config.json
{
"routes":
[
{ "path": "/", "callback": "application#index" }
],
"filters":
[
{ "path": "/", "callback": "" }
],
"websockets":
[
{ "event": "", "callback": ""}
]
}
Callbacks are in filename#functionname format
Default HTTP Method is GET. For post we need to add
"method":"post"
Web Sockets are a whole different talk. More info at
http://socket.io/
A simple Web Site
A simple Web Site
(config.json)
{
"routes":
[
{ "path": "/", "callback": "application#index" },
{ "path": "/home", "callback": "application#home" },
{ "path": "/login", "method":"post", "callback": "application#login" },
{ "path": "/logoff", "callback": "application#logoff" }
],
"filters":
[
{ "path": "/home", "callback": "session_filter#validateSession" }
],
"websockets":
[
{ "event": "", "callback": ""}
]
}
Configure your app to track
sessions
(app.js)
// initialize app
function start(app, express) {
//set favicon
app.use(express.favicon(__dirname + '/public/images/favicon.ico'));
//instantiate session management
app.use(express.session({secret: '1234567890QWERTY'}));
}
// release resources
function stop() {
}
There's more to sessions. See http://expressjs.com
A simple Web Site
(application.js)
function index(req, res) {
res.render('index', { title: 'Welcome to Node.ACS!' });
}
function login(req, res) {
var uid=req.body.uid;
var pwd=req.body.pwd;
var name=req.body.name;
if (uid==='appc' && pwd=='nodeacs'){
req.session.uid=uid;
req.session.pwd=pwd;
req.session.name=name;
res.redirect('/home');
}else{
res.send(500, { error: 'something blew up' });
}
}
function logoff(req, res) {
req.session.uid=null;
req.session.pwd=null;
req.session.name=null;
res.redirect('/');
}
function home(req, res) {
res.render('home', { title: req.session.name });
}
The Index View
(index.ejs)
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
<h2>Node.ACS</h2>
<form action="/login" method="post">
<div>Name<input type="text" name="name"/></div>
<div>UID<input type="text" name="uid"/></div>
<div>PWD<input type="password" name="pwd"/></div>
<div><input type="submit" value="Go"></div>
</form>
</body>
</html>
The Home View
(home.ejs)
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
<h2>Node.ACS</h2>
<p>Welcome Home, <%= title %>!</p>
<div><a href="/logoff">Log off</a></div>
</body>
</html>
Validating sessions
(session_filter.js)
function validateSession(req, res, next) {
if(req.session.uid === null) {
res.redirect('/');
} else {
next();
}
}
Walk-thru : ACS front-end
https://github.com/ricardoalcocer/nodeacs_sample_website
Walk-thru : SaveJSON
https://github.com/ricardoalcocer/acs_key_value_store
Creating a "catch-all" route
app.get('/get/*',function(req,res){
urlParam=req.path.replace(//$/, "").split('/').pop();
// do what you want with your url parameter
});
Some useful tools
http://www.jsontest.com/
http://www.jsoneditoronline.org/
http://posttestserver.com/
http://code.google.com/p/cocoa-rest-client/
Thank you!
Questions?
Follow me on
Twitter: @ricardoalcocer
Github: /ricardoalcocer

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Coding for entrepreneurs
Coding for entrepreneursCoding for entrepreneurs
Coding for entrepreneurs
 
Intro to the Express Web Framework
Intro to the Express Web FrameworkIntro to the Express Web Framework
Intro to the Express Web Framework
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Best Practices for creating WP REST API by Galkin Nikita
Best Practices for creating WP REST API by Galkin NikitaBest Practices for creating WP REST API by Galkin Nikita
Best Practices for creating WP REST API by Galkin Nikita
 
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
 
Write php deploy everywhere tek11
Write php deploy everywhere   tek11Write php deploy everywhere   tek11
Write php deploy everywhere tek11
 
Vagrant
VagrantVagrant
Vagrant
 
#Continuous delivery with #Deployit
#Continuous delivery with #Deployit#Continuous delivery with #Deployit
#Continuous delivery with #Deployit
 
[1C1]Service Workers
[1C1]Service Workers[1C1]Service Workers
[1C1]Service Workers
 
Express JS
Express JSExpress JS
Express JS
 
Service workers
Service workersService workers
Service workers
 
Local development with vvv jon trujillo
Local development with vvv   jon trujilloLocal development with vvv   jon trujillo
Local development with vvv jon trujillo
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
 
So I Wrote a Manifest
So I Wrote a ManifestSo I Wrote a Manifest
So I Wrote a Manifest
 
快快樂樂用Homestead
快快樂樂用Homestead快快樂樂用Homestead
快快樂樂用Homestead
 
Terraform bootstrap code_execute
Terraform bootstrap code_executeTerraform bootstrap code_execute
Terraform bootstrap code_execute
 
Openstack Vagrant plugin overview
Openstack Vagrant plugin overviewOpenstack Vagrant plugin overview
Openstack Vagrant plugin overview
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
WordPress Security 101
WordPress Security 101WordPress Security 101
WordPress Security 101
 
Vagrant crash course
Vagrant crash courseVagrant crash course
Vagrant crash course
 

Semelhante a Building websites with Node.ACS

Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
Robert Nyman
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Robert Nyman
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
Robert Nyman
 
Kraken
KrakenKraken
Kraken
PayPal
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
Edureka!
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
Frank Rousseau
 

Semelhante a Building websites with Node.ACS (20)

Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
Angularjs Tutorial for Beginners
Angularjs Tutorial for BeginnersAngularjs Tutorial for Beginners
Angularjs Tutorial for Beginners
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bits
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 
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
 
Tutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJSTutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJS
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
 
Kraken
KrakenKraken
Kraken
 
NodeJS @ ACS
NodeJS @ ACSNodeJS @ ACS
NodeJS @ ACS
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...
 
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R..."Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 
Always on! Or not?
Always on! Or not?Always on! Or not?
Always on! Or not?
 
Always on! ... or not?
Always on! ... or not?Always on! ... or not?
Always on! ... or not?
 
Workshop Ionic Framework - CC FE & UX
Workshop Ionic Framework - CC FE & UXWorkshop Ionic Framework - CC FE & UX
Workshop Ionic Framework - CC FE & UX
 

Mais de ralcocer

Develop your first mobile App for iOS and Android
Develop your first mobile App for iOS and AndroidDevelop your first mobile App for iOS and Android
Develop your first mobile App for iOS and Android
ralcocer
 
Slides for tiTokyo 2013 - Japanese version
Slides for tiTokyo 2013 - Japanese versionSlides for tiTokyo 2013 - Japanese version
Slides for tiTokyo 2013 - Japanese version
ralcocer
 

Mais de ralcocer (15)

Multi platform development using titanium + alloy
Multi platform development using titanium + alloyMulti platform development using titanium + alloy
Multi platform development using titanium + alloy
 
Develop your first mobile App for iOS and Android
Develop your first mobile App for iOS and AndroidDevelop your first mobile App for iOS and Android
Develop your first mobile App for iOS and Android
 
Slides for tiTokyo 2013 - Japanese version
Slides for tiTokyo 2013 - Japanese versionSlides for tiTokyo 2013 - Japanese version
Slides for tiTokyo 2013 - Japanese version
 
Appcelerator Alloy Deep Dive - tiTokyo 2013
Appcelerator Alloy Deep Dive - tiTokyo 2013Appcelerator Alloy Deep Dive - tiTokyo 2013
Appcelerator Alloy Deep Dive - tiTokyo 2013
 
Learning Appcelerator® Alloy™
Learning Appcelerator® Alloy™Learning Appcelerator® Alloy™
Learning Appcelerator® Alloy™
 
De Wordpress.com a Wordpress.org
De Wordpress.com a Wordpress.orgDe Wordpress.com a Wordpress.org
De Wordpress.com a Wordpress.org
 
Barcamp Mayaguez 2012
Barcamp Mayaguez 2012Barcamp Mayaguez 2012
Barcamp Mayaguez 2012
 
Cómo crear plugins para Wordpress
Cómo crear plugins para WordpressCómo crear plugins para Wordpress
Cómo crear plugins para Wordpress
 
Open Source, estándares y arquitecturas Web 2.0
Open Source, estándares y arquitecturas Web 2.0Open Source, estándares y arquitecturas Web 2.0
Open Source, estándares y arquitecturas Web 2.0
 
El pensamiento crítico y el uso de tecnología
El pensamiento crítico y el uso de tecnologíaEl pensamiento crítico y el uso de tecnología
El pensamiento crítico y el uso de tecnología
 
El OpenSource en la educación
El OpenSource en la educaciónEl OpenSource en la educación
El OpenSource en la educación
 
El valor educativo del Open Source
El valor educativo del Open SourceEl valor educativo del Open Source
El valor educativo del Open Source
 
Presentación APH
Presentación APHPresentación APH
Presentación APH
 
Educapr Oct2010
Educapr Oct2010Educapr Oct2010
Educapr Oct2010
 
The Future is Open - Pechakucha@SeriouslyCreative - August 26, 2010
The Future is Open - Pechakucha@SeriouslyCreative - August 26, 2010The Future is Open - Pechakucha@SeriouslyCreative - August 26, 2010
The Future is Open - Pechakucha@SeriouslyCreative - August 26, 2010
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Building websites with Node.ACS