SlideShare a Scribd company logo
1 of 21
A NODE.JS APPLICATION
       Robbie Clutton
NOT ANOTHER NODE.JS
           HELLO WORLD
• An   application built to run on node.js

• Concepts

• Modules   used for the application

• Modules   extracted from the application

• How    dependencies of modules was managed

• Design   decisions made during development

• Hosting
NOT ANOTHER NODE.JS
           HELLO WORLD
• An   application built to run on node.js

• Concepts

• Modules   used for the application

• Modules   extracted from the application

• How    dependencies of modules was managed

• Design   decisions made during development

• Hosting
CONCEPTS



• CommonJS      (http://www.commonjs.org)

• Lint   (http://www.javascriptlint.com/)
NOT ANOTHER NODE.JS
           HELLO WORLD
• An   application built to run on node.js

• Concepts

• Modules   used for the application

• Modules   extracted from the application

• How    dependencies of modules was managed

• Design   decisions made during development

• Hosting
TOOLBOX
• nodejs    - server side javascript vm (http://nodejs.org/)

• connect    - middleware (http://github.com/senchalabs/connect)

• express    - sinatra like routing (http://expressjs.com/)

• ndistro   - dependencies (http://github.com/visionmedia/ndistro)

• ejs   - view templates (http://github.com/visionmedia/ejs)

• mongoose- mongodb driver(http://github.com/LearnBoost/
 mongoose)

• log4js   - logging (http://github.com/csausdev/log4js-node)
CONNECT



• Middleware   framework

• Allowsfilters to be added to HTTP processing (e.g. logging,
 authentication)
CONNECT EXAMPLE
var server = Connect.createServer(
   Connect.logger(),
   function(req, res) {
       res.writeHead(200, {
      'Content-Type': 'text/plain'
      });
       res.end('Hello World');
   }
);
EXPRESS JS

var app = require('express').createServer();
app.get('/', function(req, res){
    res.send('hello world');
});
app.listen(3000);
EJS
res.render('show_username.ejs', {
  locals:{user:user}
});


                 <% if (user) { %>
                   <h2><%= user.name %></h2>
                 <% } %>
MONGOOSE
var mongoose = require('../modules/mongoose/mongoose').Mongoose;
var db = mongoose.connect('mongodb://localhost/tapas');

mongoose.model('User', {
  'properties': ['username', 'password', 'first', 'last', ...],

      'indexes': ['first', 'last', [{'username':1},{unique: true}]],

      'methods': {
         save: function(fn){
            this.updated_at = new Date();
            this.__super__(fn);
         }
       }
});

module.exports = db.model('User');
LOG4JS

var log4js = require('log4js');
log4js.addAppender(log4js.fileAppender('log/app.log'), 'controller.client');
var logger = log4js.getLogger('controller.client');
logger.setLevel('DEBUG');
logger.debug(‘hello, world’);



 [2010-09-28 19:50:24.816] [DEBUG] controller.user - hello, world
NOT ANOTHER NODE.JS
           HELLO WORLD
• An   application built to run on node.js

• Concepts

• Modules   used for the application

• Modules   extracted from the application

• How    dependencies of modules was managed

• Design   decisions made during development

• Hosting
EXTRACTED MODULES
• node-daemon   - a module for start-stop functionality without
 the need for init.d scripts (http://github.com/theteam/node-
 daemon)

• node-properties - a module for reading JSON property files
 using override pattern borrowed from Ant (http://github.com/
 theteam/node-properties)

• tapas-models
            - a module for common data entities with
 mongodb wrappers - (http://github.com/theteam/tapas-
 models)
NOT ANOTHER NODE.JS
           HELLO WORLD
• An   application built to run on node.js

• Concepts

• Modules   used for the application

• Modules   extracted from the application

• How    dependencies of modules was managed

• Design   decisions made during development

• Hosting
NDISTRO

• Bash  script that creates distributions from github for node
  binaries and modules

• Because   it’s bash, it can easily be extended

• Hash   simple syntax

• If
   modules are configured nicely, will symlink modules onto
  node execution path
NDISTRO EXAMPLE
node 0.2.0
module senchalabs connect
module visionmedia express 1.0.0beta2
module visionmedia ejs

                       ./bin/node
                       ./modules/senchalabs/connect
                       ./modules/visionmedia/express
                       ./modules/visionmedia/ejs
                       ./lib/node/connect
                       ./lib/node/express
                       ./lib/node/ejs
NOT ANOTHER NODE.JS
           HELLO WORLD
• An   application built to run on node.js

• Concepts

• Modules   used for the application

• Modules   extracted from the application

• How    dependencies of modules was managed

• Design   decisions made during development

• Hosting
DESIGN DECISIONS


• Included   everything from:

  • directory   structure

  • bootstrap   and running the application
NOT ANOTHER NODE.JS
           HELLO WORLD
• An   application built to run on node.js

• Concepts

• Modules   used for the application

• Modules   extracted from the application

• How    dependencies of modules was managed

• Design   decisions made during development

• Hosting
HOSTING



• Joyent   (https://no.de/)

• Heroku    (http://heroku.com/)

More Related Content

What's hot

System webpack-jspm
System webpack-jspmSystem webpack-jspm
System webpack-jspm
Jesse Warden
 
Xitrum HOWTOs
Xitrum HOWTOsXitrum HOWTOs
Xitrum HOWTOs
Ngoc Dao
 
Moving From Plexus To Guice
Moving From Plexus To GuiceMoving From Plexus To Guice
Moving From Plexus To Guice
Stuart McCulloch
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
Prasoon Kumar
 
Xitrum @ Scala Conference in Japan 2013
Xitrum @ Scala Conference in Japan 2013Xitrum @ Scala Conference in Japan 2013
Xitrum @ Scala Conference in Japan 2013
Ngoc Dao
 

What's hot (20)

Drupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developersDrupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developers
 
System webpack-jspm
System webpack-jspmSystem webpack-jspm
System webpack-jspm
 
Getting started with the Lupus Nuxt.js Drupal Stack
Getting started with the Lupus Nuxt.js Drupal StackGetting started with the Lupus Nuxt.js Drupal Stack
Getting started with the Lupus Nuxt.js Drupal Stack
 
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal StackDecoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
 
JBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testingJBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testing
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
 
Xitrum HOWTOs
Xitrum HOWTOsXitrum HOWTOs
Xitrum HOWTOs
 
Going offline with JS (DDD Sydney)
Going offline with JS (DDD Sydney)Going offline with JS (DDD Sydney)
Going offline with JS (DDD Sydney)
 
Moving From Plexus To Guice
Moving From Plexus To GuiceMoving From Plexus To Guice
Moving From Plexus To Guice
 
Develop plugin for Mozilla Firefox and structure a JS-based application
Develop plugin for Mozilla Firefox and structure a JS-based applicationDevelop plugin for Mozilla Firefox and structure a JS-based application
Develop plugin for Mozilla Firefox and structure a JS-based application
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
AS7
AS7AS7
AS7
 
Xitrum @ Scala Conference in Japan 2013
Xitrum @ Scala Conference in Japan 2013Xitrum @ Scala Conference in Japan 2013
Xitrum @ Scala Conference in Japan 2013
 
Pre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlifyPre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlify
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
Angular2 getting started by Stephen Lautier
Angular2 getting started by Stephen LautierAngular2 getting started by Stephen Lautier
Angular2 getting started by Stephen Lautier
 
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
 Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ... Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
 
An Overview on Nuxt.js
An Overview on Nuxt.jsAn Overview on Nuxt.js
An Overview on Nuxt.js
 
Drupal 8 Vocab Lesson
Drupal 8 Vocab LessonDrupal 8 Vocab Lesson
Drupal 8 Vocab Lesson
 

Similar to A nodejs application

Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
偉格 高
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolver
tboyt
 

Similar to A nodejs application (20)

Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting started
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done Right
 
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
 
uRequire@greecejs: An introduction to http://uRequire.org
uRequire@greecejs: An introduction to http://uRequire.orguRequire@greecejs: An introduction to http://uRequire.org
uRequire@greecejs: An introduction to http://uRequire.org
 
Mongo and node mongo dc 2011
Mongo and node mongo dc 2011Mongo and node mongo dc 2011
Mongo and node mongo dc 2011
 
Node on Windows Azure
Node on Windows AzureNode on Windows Azure
Node on Windows Azure
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Irfan maulana nodejs web development
Irfan maulana   nodejs web developmentIrfan maulana   nodejs web development
Irfan maulana nodejs web development
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolver
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
An Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows AzureAn Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows Azure
 
Let's run JavaScript Everywhere
Let's run JavaScript EverywhereLet's run JavaScript Everywhere
Let's run JavaScript Everywhere
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 

More from Robbie Clutton (7)

Api - Hacks and Hackers
Api - Hacks and HackersApi - Hacks and Hackers
Api - Hacks and Hackers
 
Options in scala
Options in scalaOptions in scala
Options in scala
 
Cache me if you can
Cache me if you canCache me if you can
Cache me if you can
 
iPhone development or how to use the web for pretty much anything
iPhone development or how to use the web for pretty much anythingiPhone development or how to use the web for pretty much anything
iPhone development or how to use the web for pretty much anything
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Pushing The Boundaries Of Continuous Integration
Pushing The Boundaries Of Continuous IntegrationPushing The Boundaries Of Continuous Integration
Pushing The Boundaries Of Continuous Integration
 
Cityuni
CityuniCityuni
Cityuni
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"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 ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

A nodejs application

  • 1. A NODE.JS APPLICATION Robbie Clutton
  • 2. NOT ANOTHER NODE.JS HELLO WORLD • An application built to run on node.js • Concepts • Modules used for the application • Modules extracted from the application • How dependencies of modules was managed • Design decisions made during development • Hosting
  • 3. NOT ANOTHER NODE.JS HELLO WORLD • An application built to run on node.js • Concepts • Modules used for the application • Modules extracted from the application • How dependencies of modules was managed • Design decisions made during development • Hosting
  • 4. CONCEPTS • CommonJS (http://www.commonjs.org) • Lint (http://www.javascriptlint.com/)
  • 5. NOT ANOTHER NODE.JS HELLO WORLD • An application built to run on node.js • Concepts • Modules used for the application • Modules extracted from the application • How dependencies of modules was managed • Design decisions made during development • Hosting
  • 6. TOOLBOX • nodejs - server side javascript vm (http://nodejs.org/) • connect - middleware (http://github.com/senchalabs/connect) • express - sinatra like routing (http://expressjs.com/) • ndistro - dependencies (http://github.com/visionmedia/ndistro) • ejs - view templates (http://github.com/visionmedia/ejs) • mongoose- mongodb driver(http://github.com/LearnBoost/ mongoose) • log4js - logging (http://github.com/csausdev/log4js-node)
  • 7. CONNECT • Middleware framework • Allowsfilters to be added to HTTP processing (e.g. logging, authentication)
  • 8. CONNECT EXAMPLE var server = Connect.createServer( Connect.logger(), function(req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World'); } );
  • 9. EXPRESS JS var app = require('express').createServer(); app.get('/', function(req, res){ res.send('hello world'); }); app.listen(3000);
  • 10. EJS res.render('show_username.ejs', { locals:{user:user} }); <% if (user) { %> <h2><%= user.name %></h2> <% } %>
  • 11. MONGOOSE var mongoose = require('../modules/mongoose/mongoose').Mongoose; var db = mongoose.connect('mongodb://localhost/tapas'); mongoose.model('User', { 'properties': ['username', 'password', 'first', 'last', ...], 'indexes': ['first', 'last', [{'username':1},{unique: true}]], 'methods': { save: function(fn){ this.updated_at = new Date(); this.__super__(fn); } } }); module.exports = db.model('User');
  • 12. LOG4JS var log4js = require('log4js'); log4js.addAppender(log4js.fileAppender('log/app.log'), 'controller.client'); var logger = log4js.getLogger('controller.client'); logger.setLevel('DEBUG'); logger.debug(‘hello, world’); [2010-09-28 19:50:24.816] [DEBUG] controller.user - hello, world
  • 13. NOT ANOTHER NODE.JS HELLO WORLD • An application built to run on node.js • Concepts • Modules used for the application • Modules extracted from the application • How dependencies of modules was managed • Design decisions made during development • Hosting
  • 14. EXTRACTED MODULES • node-daemon - a module for start-stop functionality without the need for init.d scripts (http://github.com/theteam/node- daemon) • node-properties - a module for reading JSON property files using override pattern borrowed from Ant (http://github.com/ theteam/node-properties) • tapas-models - a module for common data entities with mongodb wrappers - (http://github.com/theteam/tapas- models)
  • 15. NOT ANOTHER NODE.JS HELLO WORLD • An application built to run on node.js • Concepts • Modules used for the application • Modules extracted from the application • How dependencies of modules was managed • Design decisions made during development • Hosting
  • 16. NDISTRO • Bash script that creates distributions from github for node binaries and modules • Because it’s bash, it can easily be extended • Hash simple syntax • If modules are configured nicely, will symlink modules onto node execution path
  • 17. NDISTRO EXAMPLE node 0.2.0 module senchalabs connect module visionmedia express 1.0.0beta2 module visionmedia ejs ./bin/node ./modules/senchalabs/connect ./modules/visionmedia/express ./modules/visionmedia/ejs ./lib/node/connect ./lib/node/express ./lib/node/ejs
  • 18. NOT ANOTHER NODE.JS HELLO WORLD • An application built to run on node.js • Concepts • Modules used for the application • Modules extracted from the application • How dependencies of modules was managed • Design decisions made during development • Hosting
  • 19. DESIGN DECISIONS • Included everything from: • directory structure • bootstrap and running the application
  • 20. NOT ANOTHER NODE.JS HELLO WORLD • An application built to run on node.js • Concepts • Modules used for the application • Modules extracted from the application • How dependencies of modules was managed • Design decisions made during development • Hosting
  • 21. HOSTING • Joyent (https://no.de/) • Heroku (http://heroku.com/)

Editor's Notes