SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
INTRODUCTION TO EXPRESS
AND GRUNTJS
Peter deHaan @pdehaan pdehaan@mozilla.com

Wednesday, November 6, 13
WHAT IS EXPRESS?
Fast, unopinionated, minimalist web development framework for
Node.js. Inspired by Ruby’s Sinatra. Insanely fast, flexible, and simple.
Wednesday, November 6, 13
WHY EXPRESS?
•

Express is fast, lightweight, and... does nothing.

•

You only include the features that you need, and Express doesn’t
force you to use specific databases or frameworks.

•

5th most depended upon Node.js module.

•

Over 1900 Node.js modules use express.

•

173k downloads last week.

•

More info at http://expressjs.com/

Wednesday, November 6, 13
GETTING STARTED
1. Install Node.js: http://nodejs.org/
2. Install express module via npm (you only need to do this once):
$ [sudo] npm install express -g

3. Create a new express application named “hello-world”:
$ express hello-world

4. Install all the Node.js dependencies:
$ cd hello-world && npm install

5. Run the application:
$ node app
Wednesday, November 6, 13
CONGRATS YOU’RE NOW A
WEB DEVELOPER!
•

By default express created 6
directories, 7 files.

•

After `npm install`
(which installs all
dependencies)... 234
directories, 979 files. npm
creates a /node_modules/
directory w/ 227
subdirectories and 972 files
for all the required modules.

Wednesday, November 6, 13
COOL STORY, BRO!
$ tree
.
├── app.js
├── package.json
├── public/
│
├── images/
│
├── javascripts/
│
└── stylesheets/
│
└── style.css
├── routes/
│
├── index.js
│
└── user.js
└── views/
├── index.jade
└── layout.jade
Wednesday, November 6, 13
SAMPLE PACKAGE.JSON
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "3.4.4",
"jade": "*"
}
}

Wednesday, November 6, 13
WAIT. WHAT?
NO! OH
COME ON!
By default, express uses the Jade templating language
(which is a crime against /(read|us)ability/i). Although
there are lots of other templating languages that you
can use instead (ie: ejs, handlebars, hogan, etc):
doctype 5
html
head
title= title
link(rel='stylesheet', href='/
stylesheets/style.css')
body
block content
Wednesday, November 6, 13
OK, I’M BORED ALREADY, LETS
LOOK AT CODE

Wednesday, November 6, 13
GRUNT - THE JAVASCRIPT
TASK RUNNER
•

The greatest thing to happen
to Node.js since npm.

•

Like Ant, but better!

•

Built using Node.js/JavaScript,
so it’s “easy” to pick up and
extend and write your own
custom tasks.

•

More info at http://gruntjs.com/

Wednesday, November 6, 13
GRUNT: BY THE NUMBERS
•

4th most starred module on npm.

•

26th most depended upon Node.js module.

•

52k downloads from npm last week. 258k downloads in the last month. It’s kind of
a big deal.

•

At least 443 modules in npm are dependent on Grunt. https://npmjs.org/browse/
depended/grunt. Grunt maintains a better list at http://gruntjs.com/plugins. You can
also follow newly updated grunt- packages from npm via Twitter: @gruntweekly.

•

The Grunt core team maintains about 35 ‘official’ plugins, including ones for
CoffeeScript, Sass/Compass, compressing files/folders, concatenating files, copying
files/folders, linting/minifyng CSS/JavaScript, running test suites, blah blah blah...

Wednesday, November 6, 13
HOW DO I EVEN?
Grunt is made up of a few different pieces:
1. $ npm install grunt-cli -g: Installs the grunt CLI globally.
2. $ npm install grunt: Installs the grunt task runner into current
project.
3. $ npm install grunt-{packages}: Installs grunt plugins into
current project.
4. Create a Gruntfile.js which defines your tasks.
5. Run `grunt` from the same directory as your Gruntfile.js file and specify
optional build targets.
Wednesday, November 6, 13
AUTOMATE ALL THE THINGS!
Wednesday, November 6, 13
SAMPLE GRUNTFILE.JS
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
// Task configuration.
// [snip-snap]
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task.
grunt.registerTask('default', ['jshint', 'nodeunit']);
};

Wednesday, November 6, 13
ZZZZZZZ.....
Shut up and show me some code already!
Wednesday, November 6, 13
CREATING CUSTOM TASKS
// Impossible to read code snippet ahoy!
module.exports = function (grunt) {
grunt.initConfig({
copyright: {
files: [
"**/*.js",
"!**/node_modules/**"
],
options: {
pattern: "This Source Code Form is subject to the terms of the Mozilla Public"
}
}
});
grunt.registerMultiTask('copyright', 'Copyright all the things!', function () {
var pattern = this.options().pattern;
var files = this.filesSrc.map(function (file) {
return {
"name": file,
"txt": grunt.file.read(file, "utf8")
};
}).filter(function (file) {
return !file.txt.match(pattern);
});
if (files.length) {
grunt.log.subhead("The following files are missing copyright headers:");
files.forEach(function (file) {
grunt.log.warn(file.name);
});
return false;
}
});
grunt.registerTask('default', ['copyright']);
};

Wednesday, November 6, 13
CONCLUSION
express is a great way to quickly prototype dynamic Node.js based websites.
grunt is pretty awesome, use it.
Wednesday, November 6, 13

Mais conteúdo relacionado

Mais procurados

Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerMohammed Arif
 
Introduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentIntroduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentJames Bundey
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Dirk Ginader
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsk88hudson
 
Grunt JS - Getting Started With Grunt
Grunt JS - Getting Started With GruntGrunt JS - Getting Started With Grunt
Grunt JS - Getting Started With GruntDouglas Reynolds
 
GDG Kraków - Intro to front-end automation using bower.js & grunt.js
GDG Kraków - Intro to front-end automation using bower.js & grunt.jsGDG Kraków - Intro to front-end automation using bower.js & grunt.js
GDG Kraków - Intro to front-end automation using bower.js & grunt.jsDominik Prokop
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptLars Thorup
 
Devenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsDevenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsRémy Savard
 
Modern Development Tools
Modern Development ToolsModern Development Tools
Modern Development ToolsYe Maw
 
Automating Front-End Workflow
Automating Front-End WorkflowAutomating Front-End Workflow
Automating Front-End WorkflowDimitris Tsironis
 
Automate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsAutomate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsJosh Lee
 
How we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown UniversityHow we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown UniversityOvadiah Myrgorod
 
S&T What I know about Node 110817
S&T What I know about Node 110817S&T What I know about Node 110817
S&T What I know about Node 110817Dan Dineen
 
VCCW - Vagrant based WordPress development environment
VCCW - Vagrant based WordPress development environmentVCCW - Vagrant based WordPress development environment
VCCW - Vagrant based WordPress development environmentTakayuki Miyauchi
 

Mais procurados (20)

Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
 
Introduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentIntroduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme development
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
 
What grunt?
What grunt?What grunt?
What grunt?
 
Grunt All Day
Grunt All DayGrunt All Day
Grunt All Day
 
Npm scripts
Npm scriptsNpm scripts
Npm scripts
 
Grunt JS - Getting Started With Grunt
Grunt JS - Getting Started With GruntGrunt JS - Getting Started With Grunt
Grunt JS - Getting Started With Grunt
 
Yeoman
YeomanYeoman
Yeoman
 
GDG Kraków - Intro to front-end automation using bower.js & grunt.js
GDG Kraków - Intro to front-end automation using bower.js & grunt.jsGDG Kraków - Intro to front-end automation using bower.js & grunt.js
GDG Kraków - Intro to front-end automation using bower.js & grunt.js
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
 
Devenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsDevenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.js
 
Modern Development Tools
Modern Development ToolsModern Development Tools
Modern Development Tools
 
Automating Front-End Workflow
Automating Front-End WorkflowAutomating Front-End Workflow
Automating Front-End Workflow
 
Automate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsAutomate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.js
 
How we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown UniversityHow we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown University
 
S&T What I know about Node 110817
S&T What I know about Node 110817S&T What I know about Node 110817
S&T What I know about Node 110817
 
Webpack: from 0 to 2
Webpack: from 0 to 2Webpack: from 0 to 2
Webpack: from 0 to 2
 
VCCW - Vagrant based WordPress development environment
VCCW - Vagrant based WordPress development environmentVCCW - Vagrant based WordPress development environment
VCCW - Vagrant based WordPress development environment
 
Docker as development environment
Docker as development environmentDocker as development environment
Docker as development environment
 

Destaque

Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Samyak Bhalerao
 
Insights on Protractor testing
Insights on Protractor testingInsights on Protractor testing
Insights on Protractor testingDejan Toteff
 
Publish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsPublish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsRutvik Bapat
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpMatthew Davis
 
Publish subscribe model overview
Publish subscribe model overviewPublish subscribe model overview
Publish subscribe model overviewIshraq Al Fataftah
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsLudmila Nesvitiy
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Trung Vo Tuan
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJSstefanmayer13
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015Ben Lesh
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScriptSimon Guest
 

Destaque (12)

Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...
 
Insights on Protractor testing
Insights on Protractor testingInsights on Protractor testing
Insights on Protractor testing
 
Publish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsPublish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design Patterns
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 
Publish and Subscribe
Publish and SubscribePublish and Subscribe
Publish and Subscribe
 
Publish subscribe model overview
Publish subscribe model overviewPublish subscribe model overview
Publish subscribe model overview
 
Workshop - E2e tests with protractor
Workshop - E2e tests with protractorWorkshop - E2e tests with protractor
Workshop - E2e tests with protractor
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScript
 

Semelhante a Introduction to Express and Grunt

PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
Irfan maulana nodejs web development
Irfan maulana   nodejs web developmentIrfan maulana   nodejs web development
Irfan maulana nodejs web developmentPHP Indonesia
 
Grunt: the wild boar dev's best friend - WordCamp London 2018
Grunt: the wild boar dev's best friend - WordCamp London 2018Grunt: the wild boar dev's best friend - WordCamp London 2018
Grunt: the wild boar dev's best friend - WordCamp London 2018Marco Chiesi
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JSJacob Nelson
 
Automating WordPress Theme Development
Automating WordPress Theme DevelopmentAutomating WordPress Theme Development
Automating WordPress Theme DevelopmentHardeep Asrani
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)Ashish Gupta
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppEdureka!
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsManuel Eusebio de Paz Carmona
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end WorkflowPagepro
 
Front End Development Automation with Grunt
Front End Development Automation with GruntFront End Development Automation with Grunt
Front End Development Automation with GruntLadies Who Code
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausWomen in Technology Poland
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understandingKhalid Khan
 
Mastering ElasticSearch with Ruby and Tire
Mastering ElasticSearch with Ruby and TireMastering ElasticSearch with Ruby and Tire
Mastering ElasticSearch with Ruby and TireLuca Bonmassar
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 
Getting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress DevelopmentGetting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress DevelopmentDavid Bisset
 
Intro to Node.js
Intro to Node.jsIntro to Node.js
Intro to Node.jsJames Carr
 
Building your own personal minion with grunt.js
Building your own personal minion with grunt.jsBuilding your own personal minion with grunt.js
Building your own personal minion with grunt.jsBrent Swisher
 

Semelhante a Introduction to Express and Grunt (20)

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
 
Grunt: the wild boar dev's best friend - WordCamp London 2018
Grunt: the wild boar dev's best friend - WordCamp London 2018Grunt: the wild boar dev's best friend - WordCamp London 2018
Grunt: the wild boar dev's best friend - WordCamp London 2018
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
 
Automating WordPress Theme Development
Automating WordPress Theme DevelopmentAutomating WordPress Theme Development
Automating WordPress Theme Development
 
Using GruntJS
Using GruntJSUsing GruntJS
Using GruntJS
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
 
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
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first steps
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
 
Nodejs
NodejsNodejs
Nodejs
 
Front End Development Automation with Grunt
Front End Development Automation with GruntFront End Development Automation with Grunt
Front End Development Automation with Grunt
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understanding
 
Mastering ElasticSearch with Ruby and Tire
Mastering ElasticSearch with Ruby and TireMastering ElasticSearch with Ruby and Tire
Mastering ElasticSearch with Ruby and Tire
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
Getting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress DevelopmentGetting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress Development
 
Intro to Node.js
Intro to Node.jsIntro to Node.js
Intro to Node.js
 
Building your own personal minion with grunt.js
Building your own personal minion with grunt.jsBuilding your own personal minion with grunt.js
Building your own personal minion with grunt.js
 

Último

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Último (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

Introduction to Express and Grunt

  • 1. INTRODUCTION TO EXPRESS AND GRUNTJS Peter deHaan @pdehaan pdehaan@mozilla.com Wednesday, November 6, 13
  • 2. WHAT IS EXPRESS? Fast, unopinionated, minimalist web development framework for Node.js. Inspired by Ruby’s Sinatra. Insanely fast, flexible, and simple. Wednesday, November 6, 13
  • 3. WHY EXPRESS? • Express is fast, lightweight, and... does nothing. • You only include the features that you need, and Express doesn’t force you to use specific databases or frameworks. • 5th most depended upon Node.js module. • Over 1900 Node.js modules use express. • 173k downloads last week. • More info at http://expressjs.com/ Wednesday, November 6, 13
  • 4. GETTING STARTED 1. Install Node.js: http://nodejs.org/ 2. Install express module via npm (you only need to do this once): $ [sudo] npm install express -g 3. Create a new express application named “hello-world”: $ express hello-world 4. Install all the Node.js dependencies: $ cd hello-world && npm install 5. Run the application: $ node app Wednesday, November 6, 13
  • 5. CONGRATS YOU’RE NOW A WEB DEVELOPER! • By default express created 6 directories, 7 files. • After `npm install` (which installs all dependencies)... 234 directories, 979 files. npm creates a /node_modules/ directory w/ 227 subdirectories and 972 files for all the required modules. Wednesday, November 6, 13
  • 6. COOL STORY, BRO! $ tree . ├── app.js ├── package.json ├── public/ │ ├── images/ │ ├── javascripts/ │ └── stylesheets/ │ └── style.css ├── routes/ │ ├── index.js │ └── user.js └── views/ ├── index.jade └── layout.jade Wednesday, November 6, 13
  • 7. SAMPLE PACKAGE.JSON { "name": "application-name", "version": "0.0.1", "private": true, "scripts": { "start": "node app.js" }, "dependencies": { "express": "3.4.4", "jade": "*" } } Wednesday, November 6, 13
  • 8. WAIT. WHAT? NO! OH COME ON! By default, express uses the Jade templating language (which is a crime against /(read|us)ability/i). Although there are lots of other templating languages that you can use instead (ie: ejs, handlebars, hogan, etc): doctype 5 html head title= title link(rel='stylesheet', href='/ stylesheets/style.css') body block content Wednesday, November 6, 13
  • 9. OK, I’M BORED ALREADY, LETS LOOK AT CODE Wednesday, November 6, 13
  • 10. GRUNT - THE JAVASCRIPT TASK RUNNER • The greatest thing to happen to Node.js since npm. • Like Ant, but better! • Built using Node.js/JavaScript, so it’s “easy” to pick up and extend and write your own custom tasks. • More info at http://gruntjs.com/ Wednesday, November 6, 13
  • 11. GRUNT: BY THE NUMBERS • 4th most starred module on npm. • 26th most depended upon Node.js module. • 52k downloads from npm last week. 258k downloads in the last month. It’s kind of a big deal. • At least 443 modules in npm are dependent on Grunt. https://npmjs.org/browse/ depended/grunt. Grunt maintains a better list at http://gruntjs.com/plugins. You can also follow newly updated grunt- packages from npm via Twitter: @gruntweekly. • The Grunt core team maintains about 35 ‘official’ plugins, including ones for CoffeeScript, Sass/Compass, compressing files/folders, concatenating files, copying files/folders, linting/minifyng CSS/JavaScript, running test suites, blah blah blah... Wednesday, November 6, 13
  • 12. HOW DO I EVEN? Grunt is made up of a few different pieces: 1. $ npm install grunt-cli -g: Installs the grunt CLI globally. 2. $ npm install grunt: Installs the grunt task runner into current project. 3. $ npm install grunt-{packages}: Installs grunt plugins into current project. 4. Create a Gruntfile.js which defines your tasks. 5. Run `grunt` from the same directory as your Gruntfile.js file and specify optional build targets. Wednesday, November 6, 13
  • 13. AUTOMATE ALL THE THINGS! Wednesday, November 6, 13
  • 14. SAMPLE GRUNTFILE.JS module.exports = function (grunt) { // Project configuration. grunt.initConfig({ // Task configuration. // [snip-snap] }); // These plugins provide necessary tasks. grunt.loadNpmTasks('grunt-contrib-nodeunit'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-watch'); // Default task. grunt.registerTask('default', ['jshint', 'nodeunit']); }; Wednesday, November 6, 13
  • 15. ZZZZZZZ..... Shut up and show me some code already! Wednesday, November 6, 13
  • 16. CREATING CUSTOM TASKS // Impossible to read code snippet ahoy! module.exports = function (grunt) { grunt.initConfig({ copyright: { files: [ "**/*.js", "!**/node_modules/**" ], options: { pattern: "This Source Code Form is subject to the terms of the Mozilla Public" } } }); grunt.registerMultiTask('copyright', 'Copyright all the things!', function () { var pattern = this.options().pattern; var files = this.filesSrc.map(function (file) { return { "name": file, "txt": grunt.file.read(file, "utf8") }; }).filter(function (file) { return !file.txt.match(pattern); }); if (files.length) { grunt.log.subhead("The following files are missing copyright headers:"); files.forEach(function (file) { grunt.log.warn(file.name); }); return false; } }); grunt.registerTask('default', ['copyright']); }; Wednesday, November 6, 13
  • 17. CONCLUSION express is a great way to quickly prototype dynamic Node.js based websites. grunt is pretty awesome, use it. Wednesday, November 6, 13