SlideShare a Scribd company logo
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

PDF
Browserify
PPT
Module development
PDF
新版阿尔法城背后的前端MVC实践
PPTX
Webpack Introduction
PDF
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
PPTX
Going Offline with JS
PPTX
Webpack
PPTX
Javascript Bundling and modularization
Browserify
Module development
新版阿尔法城背后的前端MVC实践
Webpack Introduction
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
Going Offline with JS
Webpack
Javascript Bundling and modularization

What's hot (20)

PDF
Drupalcon 2021 - Nuxt.js for drupal developers
PDF
System webpack-jspm
PDF
Getting started with the Lupus Nuxt.js Drupal Stack
PDF
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
PDF
JBoss Wise: breaking barriers to WS testing
PPTX
Vue js for beginner
PDF
Xitrum HOWTOs
PPTX
Going offline with JS (DDD Sydney)
PDF
Moving From Plexus To Guice
PDF
Develop plugin for Mozilla Firefox and structure a JS-based application
PPT
Getting started with angular js
PDF
Node.js introduction
PDF
ODP
Xitrum @ Scala Conference in Japan 2013
PDF
Pre rendering media sites with nuxt.js & netlify
PDF
Complete MVC on NodeJS
PPTX
Angular2 getting started by Stephen Lautier
KEY
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
PPTX
An Overview on Nuxt.js
PDF
Drupal 8 Vocab Lesson
Drupalcon 2021 - Nuxt.js for drupal developers
System webpack-jspm
Getting started with the Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
JBoss Wise: breaking barriers to WS testing
Vue js for beginner
Xitrum HOWTOs
Going offline with JS (DDD Sydney)
Moving From Plexus To Guice
Develop plugin for Mozilla Firefox and structure a JS-based application
Getting started with angular js
Node.js introduction
Xitrum @ Scala Conference in Japan 2013
Pre rendering media sites with nuxt.js & netlify
Complete MVC on NodeJS
Angular2 getting started by Stephen Lautier
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
An Overview on Nuxt.js
Drupal 8 Vocab Lesson
Ad

Similar to A nodejs application (20)

PDF
Node.js - async for the rest of us.
PDF
Introduction to nodejs
KEY
Practical Use of MongoDB for Node.js
PDF
An introduction to Node.js
PPTX
Introduction to node.js GDD
PPTX
JS & NodeJS - An Introduction
PDF
Node js (runtime environment + js library) platform
PDF
Node js introduction
KEY
Dcjq node.js presentation
PPTX
Introduction to node.js
KEY
nodecalgary1
PDF
Build Web Apps using Node.js
PPTX
Intro to Node.js (v1)
PPTX
Introduction to Node (15th May 2017)
PPT
Node js beginner
PPTX
Introducing Node.js in an Oracle technology environment (including hands-on)
PPTX
Introduction to Node.js
PPTX
NodeJS - Server Side JS
PPT
Node js
PDF
Node azure
Node.js - async for the rest of us.
Introduction to nodejs
Practical Use of MongoDB for Node.js
An introduction to Node.js
Introduction to node.js GDD
JS & NodeJS - An Introduction
Node js (runtime environment + js library) platform
Node js introduction
Dcjq node.js presentation
Introduction to node.js
nodecalgary1
Build Web Apps using Node.js
Intro to Node.js (v1)
Introduction to Node (15th May 2017)
Node js beginner
Introducing Node.js in an Oracle technology environment (including hands-on)
Introduction to Node.js
NodeJS - Server Side JS
Node js
Node azure
Ad

More from Robbie Clutton (7)

PDF
Api - Hacks and Hackers
PPT
Options in scala
PPT
Cache me if you can
ODP
iPhone development or how to use the web for pretty much anything
PPT
Software Engineering
PPT
Pushing The Boundaries Of Continuous Integration
PPT
Api - Hacks and Hackers
Options in scala
Cache me if you can
iPhone development or how to use the web for pretty much anything
Software Engineering
Pushing The Boundaries Of Continuous Integration

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Big Data Technologies - Introduction.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
KodekX | Application Modernization Development
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Cloud computing and distributed systems.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Understanding_Digital_Forensics_Presentation.pptx
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectral efficient network and resource selection model in 5G networks
Big Data Technologies - Introduction.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Mobile App Security Testing_ A Comprehensive Guide.pdf
Unlocking AI with Model Context Protocol (MCP)
Advanced methodologies resolving dimensionality complications for autism neur...
KodekX | Application Modernization Development
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Cloud computing and distributed systems.
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Monthly Chronicles - July 2025
Encapsulation_ Review paper, used for researhc scholars
Understanding_Digital_Forensics_Presentation.pptx

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/)