SlideShare a Scribd company logo
Workshop’s repository: https://goo.gl/cjR7EL
Learn Backend JavaScript
Workshop with sample
repository.
Workshop’s repository: https://goo.gl/cjR7EL
About me
● Tsuyoshi Maeda
● A student of Code Chrysalis.
(Freelance engineer)
● I started programming at 21
years. (Junior university student.)
● What I like
○ Playing futsal (soccer)
○ Tsukemen (dipping noodles)
○ Watching video games on youtube
and Niconico.
Workshop’s repository: https://goo.gl/cjR7EL
After this meetup
● You will
○ Understand back-end programming with JavaScript.
○ Be able to set up back-end environment.
■ DB
■ Web Server
○ Create API server.
○ Be able to become a full-stack engineer. (If you are already familiar
with front-end JavaScript.)
Workshop’s repository: https://goo.gl/cjR7EL
Outline
● Advantages of JavaScript as a backend.
● Database with JavaScript
● Web server with JavaScript
● Create a API server together. (Workshop)
Today’s Repository: https://goo.gl/cjR7EL
Workshop’s repository: https://goo.gl/cjR7EL
Advantages of JavaScript as a backend.
● Don’t have to switch your brain between Front-end and Back-end.
● For web front engineers, They can start Back-end programming without
learning new programming language.
● Shortest way to become a full stack engineer. (Learning only one
programming language.)
Workshop’s repository: https://goo.gl/cjR7EL
Disadvantages of JavaScript as a backend.
● Many knowledge of back-end JavaScript are not matured compared to
other server side language.
○ NodeJS: 2009.
■ JavaScript was born on 1995 but it is not for server-side.
■ JavaScript for browser cannot handle server resources.)
○ Ruby on Rails: 2004. (Ruby: 1995)
○ PHP: 1995
■ Ruby and PHP are for server-side. (Then can handle server resources.)
● Tend to grow faster and come out new information.
○ It is hard to follow new knowledge.
Workshop’s repository: https://goo.gl/cjR7EL
Database with JavaScript
● Driver/Adapter
○ “pg “ for PostgreSQL
○ “mysql” for MySQL
○ “sqlite3” for SQLite3
● ORM (Object-relational mapping)
○ Sequelize (Most numerous of downloads and stars on Github.)
○ Bookshelf with knex (Second largest numerous of downloads and stars.)
○ https://npmcompare.com/compare/bookshelf,knex,objection,orm,sequelize
Workshop’s repository: https://goo.gl/cjR7EL
Driver/Adapter
Web Server DB
pg
mysql
sqlite3
driver/adapter
Return raw data
Communicate with DB like client
on shell.
Workshop’s repository: https://goo.gl/cjR7EL
ORM
Web
Server
DB
pg
mysql
sqlite3
connector/adapter
Return raw data
Communicate with DB like client
on shell.
ORM
● Return raw data
● Convert to data that
is easy to
manipulate.
Workshop’s repository: https://goo.gl/cjR7EL
ORM
● Instead of using raw SQL, ORM offers some methods that translate into
SQL.
○ e.g.) Code snippets of Sequelize to manipulate Todos table.
■ Todo.findAll({...}) => SELECT ...
■ Todo.create({...}) => INSERT ..., UPDATE ...
■ Todo.findAll({include: [{model: ‘User’}...]}) => Join
■ and so on …
● You don’t have to care about each dialect of DB.
● Just change adapter when you want to change DB.
Workshop’s repository: https://goo.gl/cjR7EL
Web server with JavaScript
● Express (Most popular node http framework and we will use this for
today’s workshop.)
○ Middlewares
○ Router
● Other JavaScript web frameworks
○ Socket.io
○ Hapi.js
○ Sails.js
Workshop’s repository: https://goo.gl/cjR7EL
Middleware
● Middleware converts request to what you can handle easily.
○ Check if user is logged in or not.
○ Log HTTP requests
○ Parse request body of Json to object of JavaScript.
● The Express middleware modules maintained by the Expressjs team.
○ https://expressjs.com/en/resources/middleware.html
Workshop’s repository: https://goo.gl/cjR7EL
Web Server
Middleware
DBClient
Middleware
process 1
process 2
...
process n-1
router
Connect to DB if a process has a code
that communicate with DB.
Request /api/data
Response /api/data
Workshop’s repository: https://goo.gl/cjR7EL
Middleware
● Example code of middleware
// req: Includes req object and can modify req object
// res: Includes res object
// next: callback function to call next middleware or router.
function(req, res, next) {
req.body = …; // You can add any properties
res.statusCode = …;
// If you want to stop this process, do not call `next` callback.
if( condition ) return false;
next();
}
Workshop’s repository: https://goo.gl/cjR7EL
● Router handle each request and direct the request to proper process.
○ GET /path/to/something
● You can map one URL to each HTTP methods.
○ “GET” for getting data.
○ “POST” for creating new data.
○ “PUT” for updating stored data.
○ “DELETE” for deleting stored data.
● CRUD
○ Create, Read, Update, Delete
Router
Workshop’s repository: https://goo.gl/cjR7EL
Web Server
Router
DBClient
Connect to DB if a process(controller)
has a code that communicate with DB.
Router
GET
POST
PUT
DELETE
Controller
fetchData
createData
updateData
deleteData
Request /api/data
Response /api/data
Mapping request to controller/handler by
HTTP methods.
Workshop’s repository: https://goo.gl/cjR7EL
Router, Controller
● Example code of router
const router = require('express').Router();
const controller = require('./api.controller');
router.route('/todos')
.get(controller.getTodos)
.post(controller.postTodo)
.put(controller.putTodo)
.delete(controller.deleteTodo);
● Example code of Controller
module.exports = {
getTodos(req, res) {...},
postTodos(req, res) {...},
putTodos(req, res) {...},
deleteTodos(req, res) {...}
};
Workshop’s repository: https://goo.gl/cjR7EL
Web Server
Middleware and Router
DB
Client
Router
GET
POST
PUT
DELETE
Controller
fetchData
createData
updateData
deleteData
Request:
GET /api/data
Response:
GET /api/data
Middleware
process 1
process 2
...
Workshop’s repository: https://goo.gl/cjR7EL
DB
Web Server
Client
Router
GET
POST
PUT
DELETE
Controller
fetchData
createDat
a
updateDat
a
deleteDat
a
Middleware
process 1
process 2
...
pg
mysql
sqlite3
ORM
ORM, Middleware and Router
Workshop’s repository: https://goo.gl/cjR7EL
● DB
○ What is a driver/adapter?
○ What is a ORM?
● Web server
○ What is a middleware?
○ What is a router?
○ When user request to server, how does the data flow works?
Recap
Workshop’s repository: https://goo.gl/cjR7EL
Let’s create a API server together!!!
https://goo.gl/cjR7EL
Workshop time
Workshop’s repository: https://goo.gl/cjR7EL
My contacts
● Twitter: @duyoji
● Github: duyoji
● Blog
○ http://duyoji.hatenablog.com/ (Written in Japanese and not only Tech blog.)
○ http://tsuyoshi-maeda.hatenablog.com/ (Written in English and only Tech blog.)

More Related Content

What's hot

Big mountain data competition training: scraping-n-munge
Big mountain data competition training: scraping-n-mungeBig mountain data competition training: scraping-n-munge
Big mountain data competition training: scraping-n-munge
David "Gonzo" Gonzalez
 
Grooscript and Grails 3
Grooscript and Grails 3Grooscript and Grails 3
Grooscript and Grails 3
Jorge Franco Leza
 
MLBlock
MLBlockMLBlock
MLBlock
Nat Weerawan
 
Indexes don't mean slow inserts.
Indexes don't mean slow inserts.Indexes don't mean slow inserts.
Indexes don't mean slow inserts.
Anastasia Lubennikova
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodbLee Theobald
 
Puppet Camp Ghent 2013
Puppet Camp Ghent 2013Puppet Camp Ghent 2013
Puppet Camp Ghent 2013
Server Density
 
Introduction to Gulp
Introduction to GulpIntroduction to Gulp
Introduction to Gulp
apdhtg6
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JSFestUA
 
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
Vitalii Kukhar
 
Creating ASTTs The painful truth
Creating ASTTs The painful truthCreating ASTTs The painful truth
Creating ASTTs The painful truth
Mario García
 
PHP and node.js Together
PHP and node.js TogetherPHP and node.js Together
PHP and node.js Together
Chris Tankersley
 
What Reika Taught us
What Reika Taught usWhat Reika Taught us
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
Norberto Leite
 
იოსებ ძმანაშვილი Node.js
იოსებ ძმანაშვილი   Node.jsიოსებ ძმანაშვილი   Node.js
იოსებ ძმანაშვილი Node.js
unihack
 
Not only SQL
Not only SQL Not only SQL
Not only SQL
Niklas Gustavsson
 
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Badoo Development
 
Video WebChat Conference Tool
Video WebChat Conference ToolVideo WebChat Conference Tool
Video WebChat Conference ToolSergiu Gordienco
 
Pgconf asia-201612203-pg reversi
Pgconf asia-201612203-pg reversiPgconf asia-201612203-pg reversi
Pgconf asia-201612203-pg reversi
Toshi Harada
 

What's hot (20)

Big mountain data competition training: scraping-n-munge
Big mountain data competition training: scraping-n-mungeBig mountain data competition training: scraping-n-munge
Big mountain data competition training: scraping-n-munge
 
Grooscript and Grails 3
Grooscript and Grails 3Grooscript and Grails 3
Grooscript and Grails 3
 
MLBlock
MLBlockMLBlock
MLBlock
 
Indexes don't mean slow inserts.
Indexes don't mean slow inserts.Indexes don't mean slow inserts.
Indexes don't mean slow inserts.
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
 
Puppet Camp Ghent 2013
Puppet Camp Ghent 2013Puppet Camp Ghent 2013
Puppet Camp Ghent 2013
 
Introduction to Gulp
Introduction to GulpIntroduction to Gulp
Introduction to Gulp
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
 
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
 
Arctic stack
Arctic stackArctic stack
Arctic stack
 
Creating ASTTs The painful truth
Creating ASTTs The painful truthCreating ASTTs The painful truth
Creating ASTTs The painful truth
 
PHP and node.js Together
PHP and node.js TogetherPHP and node.js Together
PHP and node.js Together
 
What Reika Taught us
What Reika Taught usWhat Reika Taught us
What Reika Taught us
 
Qtp word methods
Qtp word methodsQtp word methods
Qtp word methods
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
იოსებ ძმანაშვილი Node.js
იოსებ ძმანაშვილი   Node.jsიოსებ ძმანაშვილი   Node.js
იოსებ ძმანაშვილი Node.js
 
Not only SQL
Not only SQL Not only SQL
Not only SQL
 
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
 
Video WebChat Conference Tool
Video WebChat Conference ToolVideo WebChat Conference Tool
Video WebChat Conference Tool
 
Pgconf asia-201612203-pg reversi
Pgconf asia-201612203-pg reversiPgconf asia-201612203-pg reversi
Pgconf asia-201612203-pg reversi
 

Similar to Learn backend java script

Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
Andrew Rota
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with DancerModern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
Dave Cross
 
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
Women in Technology Poland
 
Tech meetup: Web Applications Performance
Tech meetup: Web Applications PerformanceTech meetup: Web Applications Performance
Tech meetup: Web Applications PerformanceSantex Group
 
Building an analytics workflow using Apache Airflow
Building an analytics workflow using Apache AirflowBuilding an analytics workflow using Apache Airflow
Building an analytics workflow using Apache Airflow
Yohei Onishi
 
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
Holden Karau
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
Andy Bunce
 
Xephon K A Time series database with multiple backends
Xephon K A Time series database with multiple backendsXephon K A Time series database with multiple backends
Xephon K A Time series database with multiple backends
University of California, Santa Cruz
 
Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application
Andy Bunce
 
React starter-kitでとっとと始めるisomorphic開発
React starter-kitでとっとと始めるisomorphic開発React starter-kitでとっとと始めるisomorphic開発
React starter-kitでとっとと始めるisomorphic開発
Yoichi Toyota
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easy
Alexander Kukushkin
 
Accumulo Summit Keynote 2018
Accumulo Summit Keynote 2018Accumulo Summit Keynote 2018
Accumulo Summit Keynote 2018
Accumulo Summit
 
Monitoring Kafka w/ Prometheus
Monitoring Kafka w/ PrometheusMonitoring Kafka w/ Prometheus
Monitoring Kafka w/ Prometheus
kawamuray
 
Intro - End to end ML with Kubeflow @ SignalConf 2018
Intro - End to end ML with Kubeflow @ SignalConf 2018Intro - End to end ML with Kubeflow @ SignalConf 2018
Intro - End to end ML with Kubeflow @ SignalConf 2018
Holden Karau
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
Adrian Caetano
 
Catalyst MVC
Catalyst MVCCatalyst MVC
Catalyst MVC
Sheeju Alex
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
Masashi Umezawa
 
202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP
Ronald Hsu
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
Aleksander Alekseev
 
Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013
Mauricio (Salaboy) Salatino
 

Similar to Learn backend java script (20)

Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with DancerModern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
 
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
 
Tech meetup: Web Applications Performance
Tech meetup: Web Applications PerformanceTech meetup: Web Applications Performance
Tech meetup: Web Applications Performance
 
Building an analytics workflow using Apache Airflow
Building an analytics workflow using Apache AirflowBuilding an analytics workflow using Apache Airflow
Building an analytics workflow using Apache Airflow
 
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
 
Xephon K A Time series database with multiple backends
Xephon K A Time series database with multiple backendsXephon K A Time series database with multiple backends
Xephon K A Time series database with multiple backends
 
Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application
 
React starter-kitでとっとと始めるisomorphic開発
React starter-kitでとっとと始めるisomorphic開発React starter-kitでとっとと始めるisomorphic開発
React starter-kitでとっとと始めるisomorphic開発
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easy
 
Accumulo Summit Keynote 2018
Accumulo Summit Keynote 2018Accumulo Summit Keynote 2018
Accumulo Summit Keynote 2018
 
Monitoring Kafka w/ Prometheus
Monitoring Kafka w/ PrometheusMonitoring Kafka w/ Prometheus
Monitoring Kafka w/ Prometheus
 
Intro - End to end ML with Kubeflow @ SignalConf 2018
Intro - End to end ML with Kubeflow @ SignalConf 2018Intro - End to end ML with Kubeflow @ SignalConf 2018
Intro - End to end ML with Kubeflow @ SignalConf 2018
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
 
Catalyst MVC
Catalyst MVCCatalyst MVC
Catalyst MVC
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
 
202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
 
Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013
 

Recently uploaded

E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 

Recently uploaded (20)

E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 

Learn backend java script

  • 1. Workshop’s repository: https://goo.gl/cjR7EL Learn Backend JavaScript Workshop with sample repository.
  • 2. Workshop’s repository: https://goo.gl/cjR7EL About me ● Tsuyoshi Maeda ● A student of Code Chrysalis. (Freelance engineer) ● I started programming at 21 years. (Junior university student.) ● What I like ○ Playing futsal (soccer) ○ Tsukemen (dipping noodles) ○ Watching video games on youtube and Niconico.
  • 3. Workshop’s repository: https://goo.gl/cjR7EL After this meetup ● You will ○ Understand back-end programming with JavaScript. ○ Be able to set up back-end environment. ■ DB ■ Web Server ○ Create API server. ○ Be able to become a full-stack engineer. (If you are already familiar with front-end JavaScript.)
  • 4. Workshop’s repository: https://goo.gl/cjR7EL Outline ● Advantages of JavaScript as a backend. ● Database with JavaScript ● Web server with JavaScript ● Create a API server together. (Workshop) Today’s Repository: https://goo.gl/cjR7EL
  • 5. Workshop’s repository: https://goo.gl/cjR7EL Advantages of JavaScript as a backend. ● Don’t have to switch your brain between Front-end and Back-end. ● For web front engineers, They can start Back-end programming without learning new programming language. ● Shortest way to become a full stack engineer. (Learning only one programming language.)
  • 6. Workshop’s repository: https://goo.gl/cjR7EL Disadvantages of JavaScript as a backend. ● Many knowledge of back-end JavaScript are not matured compared to other server side language. ○ NodeJS: 2009. ■ JavaScript was born on 1995 but it is not for server-side. ■ JavaScript for browser cannot handle server resources.) ○ Ruby on Rails: 2004. (Ruby: 1995) ○ PHP: 1995 ■ Ruby and PHP are for server-side. (Then can handle server resources.) ● Tend to grow faster and come out new information. ○ It is hard to follow new knowledge.
  • 7. Workshop’s repository: https://goo.gl/cjR7EL Database with JavaScript ● Driver/Adapter ○ “pg “ for PostgreSQL ○ “mysql” for MySQL ○ “sqlite3” for SQLite3 ● ORM (Object-relational mapping) ○ Sequelize (Most numerous of downloads and stars on Github.) ○ Bookshelf with knex (Second largest numerous of downloads and stars.) ○ https://npmcompare.com/compare/bookshelf,knex,objection,orm,sequelize
  • 8. Workshop’s repository: https://goo.gl/cjR7EL Driver/Adapter Web Server DB pg mysql sqlite3 driver/adapter Return raw data Communicate with DB like client on shell.
  • 9. Workshop’s repository: https://goo.gl/cjR7EL ORM Web Server DB pg mysql sqlite3 connector/adapter Return raw data Communicate with DB like client on shell. ORM ● Return raw data ● Convert to data that is easy to manipulate.
  • 10. Workshop’s repository: https://goo.gl/cjR7EL ORM ● Instead of using raw SQL, ORM offers some methods that translate into SQL. ○ e.g.) Code snippets of Sequelize to manipulate Todos table. ■ Todo.findAll({...}) => SELECT ... ■ Todo.create({...}) => INSERT ..., UPDATE ... ■ Todo.findAll({include: [{model: ‘User’}...]}) => Join ■ and so on … ● You don’t have to care about each dialect of DB. ● Just change adapter when you want to change DB.
  • 11. Workshop’s repository: https://goo.gl/cjR7EL Web server with JavaScript ● Express (Most popular node http framework and we will use this for today’s workshop.) ○ Middlewares ○ Router ● Other JavaScript web frameworks ○ Socket.io ○ Hapi.js ○ Sails.js
  • 12. Workshop’s repository: https://goo.gl/cjR7EL Middleware ● Middleware converts request to what you can handle easily. ○ Check if user is logged in or not. ○ Log HTTP requests ○ Parse request body of Json to object of JavaScript. ● The Express middleware modules maintained by the Expressjs team. ○ https://expressjs.com/en/resources/middleware.html
  • 13. Workshop’s repository: https://goo.gl/cjR7EL Web Server Middleware DBClient Middleware process 1 process 2 ... process n-1 router Connect to DB if a process has a code that communicate with DB. Request /api/data Response /api/data
  • 14. Workshop’s repository: https://goo.gl/cjR7EL Middleware ● Example code of middleware // req: Includes req object and can modify req object // res: Includes res object // next: callback function to call next middleware or router. function(req, res, next) { req.body = …; // You can add any properties res.statusCode = …; // If you want to stop this process, do not call `next` callback. if( condition ) return false; next(); }
  • 15. Workshop’s repository: https://goo.gl/cjR7EL ● Router handle each request and direct the request to proper process. ○ GET /path/to/something ● You can map one URL to each HTTP methods. ○ “GET” for getting data. ○ “POST” for creating new data. ○ “PUT” for updating stored data. ○ “DELETE” for deleting stored data. ● CRUD ○ Create, Read, Update, Delete Router
  • 16. Workshop’s repository: https://goo.gl/cjR7EL Web Server Router DBClient Connect to DB if a process(controller) has a code that communicate with DB. Router GET POST PUT DELETE Controller fetchData createData updateData deleteData Request /api/data Response /api/data Mapping request to controller/handler by HTTP methods.
  • 17. Workshop’s repository: https://goo.gl/cjR7EL Router, Controller ● Example code of router const router = require('express').Router(); const controller = require('./api.controller'); router.route('/todos') .get(controller.getTodos) .post(controller.postTodo) .put(controller.putTodo) .delete(controller.deleteTodo); ● Example code of Controller module.exports = { getTodos(req, res) {...}, postTodos(req, res) {...}, putTodos(req, res) {...}, deleteTodos(req, res) {...} };
  • 18. Workshop’s repository: https://goo.gl/cjR7EL Web Server Middleware and Router DB Client Router GET POST PUT DELETE Controller fetchData createData updateData deleteData Request: GET /api/data Response: GET /api/data Middleware process 1 process 2 ...
  • 19. Workshop’s repository: https://goo.gl/cjR7EL DB Web Server Client Router GET POST PUT DELETE Controller fetchData createDat a updateDat a deleteDat a Middleware process 1 process 2 ... pg mysql sqlite3 ORM ORM, Middleware and Router
  • 20. Workshop’s repository: https://goo.gl/cjR7EL ● DB ○ What is a driver/adapter? ○ What is a ORM? ● Web server ○ What is a middleware? ○ What is a router? ○ When user request to server, how does the data flow works? Recap
  • 21. Workshop’s repository: https://goo.gl/cjR7EL Let’s create a API server together!!! https://goo.gl/cjR7EL Workshop time
  • 22. Workshop’s repository: https://goo.gl/cjR7EL My contacts ● Twitter: @duyoji ● Github: duyoji ● Blog ○ http://duyoji.hatenablog.com/ (Written in Japanese and not only Tech blog.) ○ http://tsuyoshi-maeda.hatenablog.com/ (Written in English and only Tech blog.)