SlideShare a Scribd company logo
1 of 19
www.fg.cz
Využití NodeJS pro Javisty
Michal Franc
2
3
4
5
TEST
snadná instalace
množství test runnerů / frameworků / assert
6
var request = require('supertest');
var base = require('../base.js');
request = request(base.baseUrl);
describe('úložiště obrázky', function() {
it('poskytuje uložený obsah dle uri', function(done) {
request
.get('/storage/pictures/logo.jpg‚)
.auth(base.user,base.pass)
.expect('Content-Type', /image/)
.expect('Cache-Control', /600/)
.expect(200, done);
})
});
7
var request = require('supertest'); var base = require('../base.js');
var cheerio = require('cheerio'); var should = require('should');
request = request(base.baseUrl);
describe('Úvodní stránka', function() {
before(function(done) {
request.get('/homepage.html').auth(base.user,base.pass)
.end(function(err, res) {
if (err) return done(err);
this.doc = cheerio.load(res.text); done();
}.bind(this));
});
it('obsahuje zprávy za 1-10dní', function() {
this.doc('#middle').find('.one-day-line').length
.should.within(1,10);
});
});
8
CLI
integrace do command line
9
> npm install –g yo
> sudo npm install -g yo@1.1.2
10
Yeoman – YO
project scaffolding
11
12
• Založení projektu – edeecms generátor
• Načte developer settings
• Provede git pull kostry projektu
• Zeptá se na vlastnosti projektu, výběr modulů
• Dle výběru zkopíruje složky z kostry
• Vygeneruje heslo do db
• Založí databázi
• Stáhne základní závislosti pro další provoz
• Modifikace projektu – subgenerátor
• Přidání modulu
• Založení databáze
13
14
Grunt
task runner
buildování js, css
15
> grunt server
16
> grunt deployWar
17
> grunt deployWar
sshexec: {
deployWar: {
command: [
'cd <%= projectRoot %>/<%= warRoot %>',
'mv ./<%= expandedWar %>'+
' ./backup/<%= expandedWar %>'+
'<%= grunt.template.today("yyyymmdd-HHMMss") %>',
'rm -rf ./<%= expandedWar %>/',
'unzip -o ./<%= warFile %>'+
' -d ./<%= expandedWar %>',
'rm ./<%= warFile %>',
'find ./backup/ -maxdepth 1 -ctime +3 | xargs rm -rf'
].join(' && '),
options: { config: 'sshsettings' }
}}
18
NodeJS – npm
Mocha (Jasmine)
Yeoman
Bower
Grunt (Gulp)
19
Proč?

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Využití NodeJS pro Javisty - jOpenSpace 2014

  • 1. www.fg.cz Využití NodeJS pro Javisty Michal Franc
  • 2. 2
  • 3. 3
  • 4. 4
  • 5. 5 TEST snadná instalace množství test runnerů / frameworků / assert
  • 6. 6 var request = require('supertest'); var base = require('../base.js'); request = request(base.baseUrl); describe('úložiště obrázky', function() { it('poskytuje uložený obsah dle uri', function(done) { request .get('/storage/pictures/logo.jpg‚) .auth(base.user,base.pass) .expect('Content-Type', /image/) .expect('Cache-Control', /600/) .expect(200, done); }) });
  • 7. 7 var request = require('supertest'); var base = require('../base.js'); var cheerio = require('cheerio'); var should = require('should'); request = request(base.baseUrl); describe('Úvodní stránka', function() { before(function(done) { request.get('/homepage.html').auth(base.user,base.pass) .end(function(err, res) { if (err) return done(err); this.doc = cheerio.load(res.text); done(); }.bind(this)); }); it('obsahuje zprávy za 1-10dní', function() { this.doc('#middle').find('.one-day-line').length .should.within(1,10); }); });
  • 9. 9 > npm install –g yo > sudo npm install -g yo@1.1.2
  • 11. 11
  • 12. 12 • Založení projektu – edeecms generátor • Načte developer settings • Provede git pull kostry projektu • Zeptá se na vlastnosti projektu, výběr modulů • Dle výběru zkopíruje složky z kostry • Vygeneruje heslo do db • Založí databázi • Stáhne základní závislosti pro další provoz • Modifikace projektu – subgenerátor • Přidání modulu • Založení databáze
  • 13. 13
  • 17. 17 > grunt deployWar sshexec: { deployWar: { command: [ 'cd <%= projectRoot %>/<%= warRoot %>', 'mv ./<%= expandedWar %>'+ ' ./backup/<%= expandedWar %>'+ '<%= grunt.template.today("yyyymmdd-HHMMss") %>', 'rm -rf ./<%= expandedWar %>/', 'unzip -o ./<%= warFile %>'+ ' -d ./<%= expandedWar %>', 'rm ./<%= warFile %>', 'find ./backup/ -maxdepth 1 -ctime +3 | xargs rm -rf' ].join(' && '), options: { config: 'sshsettings' } }}
  • 18. 18 NodeJS – npm Mocha (Jasmine) Yeoman Bower Grunt (Gulp)

Editor's Notes

  1. Reálné use casy použití Doplnit možnosti Vaší aplikace
  2. Nodejs stojí za pozornost Mladá technologie
  3. NodeJS staví na JS enginu Google V8 Míří na síťové aplikace, rest API apod., silné jsou i webové aplikace Kolem V8 jsou async IO API
  4. NodeJS je používán pro workflow v rámci webdevelopmentu Pokud nepoužíváte, měli byste vyzkoušet
  5. Jednoduchá instalace Na výběr je několik test runnerů – Jasmine, Mocha, Karma
  6. Jednoduchý test hlaviček
  7. Snadno parsovat stránku
  8. Oproti javě je instalace dotaženější v integraci na cli NPM install -g
  9. Založení projektu Mvn archetype sucks
  10. Založení projektu pomocí yeoman umí řešit i složitější porces Příklad pro založení Edee CMS projektu
  11. Změny lze diffnout
  12. Task runner Primárně build js, css
  13. Pomocí grunt tasku lze stáhnout webovou aplikaci s embedovaným Tomcat, rychlé spoustění projektu bez konfigurace
  14. Grunt task na deployment pomocí ssh
  15. Nabízí se pro poskytování služeb pro testery, technické uživatele aplikace Rozšíříte si obzory – díky tomu můžete přijít s něčím novým