Node - Express (Web Framework)

About

Express 1) is a node http server (web server)

Sample app

  • Install express
npm install express 
  • Javascript
const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))
  • Start the server
node app.js
Example app listening on port 3000!

Hello World

Generator

http://expressjs.com/en/starter/generator.html

The app structure created by the generator is just one of many ways to structure Express apps

.
├── app.js
├── bin
│   └── www
├── package.json
├── public
│   ├── images
│   ├── javascripts
│   └── stylesheets
│       └── style.css
├── routes
│   ├── index.js
│   └── users.js
└── views
    ├── error.pug
    ├── index.pug
    └── layout.pug

Routing

http://expressjs.com/en/starter/basic-routing.html

Reload

backend development server that will give you hot-redeploy

npm i nodemon -g

Documentation / Reference





Discover More
Cors Flowchart
Browser - Cross Origin Resource Sharing (CORS)

Cross-origin resource sharing (CORS) is a mechanism that: * allows a HTTP server * to control the cross-origin requests executed by a browser. In short, a HTTP server may allow or not to receive...
Node - Web Server

in Node. With http.createServer with npm
React - Deployment - Routing for client side router

With client side router, a direct HTTP call will failed if you are not using some routing features (such as ) For a create-react-app React application, all URL must be redirected to the index.html...
React - Proxy to a backend

How to proxy request to a backend in React. To tell the development server to proxy any unknown requests to your API server in development, add a proxy field to your package.json, for example: ...
React Framework - Next.js

Next is a React framework for server-rendered React applications. isomorphic apps (code that runs in the browser or in node) note from the getting started...
Web - Framework

This framework provides an http server with at minimal a routing capability and adds above other features such as: templating authentication Framework Description Languages Vertx The reactive...
What is a (HTTP) handler ?

A handler is a method that process an HTTP request and pass it to the next handler or return a response. If you want more details, this articles gives you them to the point.



Share this page:
Follow us:
Task Runner