JavaScript: ExpressJS Overview

Slides:



Advertisements
Similar presentations
AngularJS Routing Routes, Route Parameters, Templates, Location, Navigation SoftUni Team Technical Trainers Software University
Advertisements

Trainers Team Ivan Yonkov Rated in the top 7% at Stack Overflow
AMD and RequireJS Splitting JavaScript Code into Dependent Modules Software University Technical Trainers SoftUni Team.
First Steps in PHP Creating Very Simple PHP Scripts SoftUni Team Technical Trainers Software University
Software Technologies
Magento Basics Getting started developing for Magento
Introduction to Entity framework
Databases basics Course Introduction SoftUni Team Databases basics
Sockets, Routing, Sessions, Handlers
C# Basic Syntax, Visual Studio, Console Input / Output
Interface Segregation / Dependency Inversion
Services & Dependency Injection
C# MVC Frameworks – ASP.NET
ASP.NET Essentials SoftUni Team ASP.NET MVC Introduction
C# Basic Syntax, Visual Studio, Console Input / Output
Web API - Introduction AJAX, Spring Data REST SoftUni Team Web API
Introduction to MVC SoftUni Team Introduction to MVC
Deploying Web Application
Thymeleaf and Spring Controllers
WordPress Introduction
PHP MVC Frameworks Course Introduction SoftUni Team Technical Trainers
PHP Fundamentals Course Introduction SoftUni Team Technical Trainers
C# Database Fundamentals with Microsoft SQL Server
JavaScript Applications
Introduction to Entity Framework
ASP.NET Integration Testing
ASP.NET Unit Testing Unit Testing Web API SoftUni Team ASP.NET
Mocking tools for easier unit testing
JavaScript Applications
State Management Cookies, Sessions SoftUni Team State Management
Browser Routing Design Patterns in JS
EF Code First (Advanced)
PHP MVC Frameworks MVC Fundamentals SoftUni Team Technical Trainers
C# Databases Advanced with Microsoft SQL Server
Spring Filters Spring Interceptors SoftUni Team Spring Interceptors
Software Technologies
EF Relations Object Composition
Entity Framework: Code First
Registration, Login, Thymeleaf
Unit Testing with Mocha
Databases advanced Course Introduction SoftUni Team Databases advanced
C#/Java Web Development Basics
MVC Architecture. Routing
Entity Framework: Relations
The Right Way Control Flow
ASP.NET Razor Engine SoftUni Team ASP.NET MVC Introduction
MVC Architecture, Symfony Framework for PHP Web Apps
AJAX and jQuery AJAX AJAX Concepts, XMLHttpRequest, jQuery AJAX: $.ajax(), $.get(), $.post() jQuery AJAX XMLHttpRequest SoftUni Team Technical Trainers.
ASP.NET MVC Introduction
C# Advanced Course Introduction SoftUni Team C# Technical Trainers
Databases Advanced Course Introduction SoftUni Team Databases Advanced
Best Practices and Architecture
C# Web Development Basics
Creating UI elements with Handlebars
Best practices and architecture
Design & Module Development
Extending functionality using Collections
ASP.NET Filters SoftUni Team ASP.NET MVC Introduction
ASP.NET Razor Engine SoftUni Team ASP.NET MVC Introduction
C# Advanced Course Introduction SoftUni Team C# Technical Trainers
Course Overview, Trainers, Evaluation
Scheduled Tasks and Web Socket
JavaScript Fundamentals
Introduction to TypeScript & Angular
CSS Transitions and Animations
Train the Trainers Course
Version Control Systems
JavaScript Frameworks & AngularJS
Lean .NET stack for building modern web apps
Iterators and Generators
Presentation transcript:

JavaScript: ExpressJS Overview Node.JS, ExpressJS, Handlebars, MVC in JavaScript ExpressJS SoftUni Team Technical Trainers Software University http://softuni.bg

Contents Node.JS ExpressJS What is ExpressJS? Routes Controllers Overview, Purpose ExpressJS What is ExpressJS? Routes Controllers Views – using handlebars.js

Have a Question? sli.do #tech-softuni

Server-side JavaScript runtime Node.JS Server-side JavaScript runtime

Node.JS – What is it? Node.JS – JavaScript runtime environment Run JavaScript from the console Flexible – can use various modules Scalable – works well for both small and large workloads Can act as a Web Server

Node.JS - Advantages Developers can use whatever they want for: Middleware Authentication, Cookies, Sessions (User Login State) Database connection + ORM (DB to Entity) Mongoose, Sequelize, Bookshelf, etc. Template (view) engines Handlebars, Pug, Mustache, etc.

Node.JS Example – Simple Web server Anonymous function Send a response Listen on port 8080 Request URL HTTP Response (rendered as web page)

Web Framework for Node.JS ExpressJS Web Framework for Node.JS

What is ExpressJS? Web framework for Node.JS Handles GET, POST requests Error handling (bad request, not found, unauthorized) Advanced routing (parameters and wildcards supported) Parameters Parameters Wildcard (anything)

ExpressJS Routing Specify HTTP Request method (GET/POST) Function to execute when route is matched Express instance URI (path on server) Request & Response

Using Node.JS, ExpressJS, Handlebars, Mongoose MVC Pattern Using Node.JS, ExpressJS, Handlebars, Mongoose

Routes – routes.js Routes.js allows us to tell ExpressJS which routes trigger which controller actions Import the cat controller Handles GET requests Route to listen on Call the details function

Model – Mongoose Using Mongoose, we can define our model schema: Unique ID Model properties Validation Model name

View – Handlebars HTML views with Handlebars templating syntax: Handlebars syntax Handlebars syntax HTML Code Handlebars if/else

View – Handlebars (2) Route: /cat/details/ req.params.id {{cat.name}} {{cat.age}}

Controller – ExpressJS Example – catController.js: Import the Cat model Controller action Find cat in DB by id Render error view Render cat/details view Pass parameters to view

Problem: Simple Calculator Web Application Write a web application, which can calculate the result between two operands Implement addition, subtraction, multiplication and division

Web application with ExpressJS Live Exercises in Class (Lab)

Summary Node.JS JavaScript runtime environment ExpressJS Establishes communication between the server, and the client ExpressJS Web framework for Node.JS Implementing the MVC pattern with JavaScript Using Node.JS, Mongoose, ExpressJS and Handlebars

JavaScript: ExpressJS Overview https://softuni.bg/courses/software-technologies/ © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license.

License This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" license © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license.

Trainings @ Software University Software University Foundation – softuni.org Software University – High-Quality Education, Profession and Job for Software Developers softuni.bg Software University @ Facebook facebook.com/SoftwareUniversity Software University Forums – forum.softuni.bg © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license.