Node - Express (Web Framework)

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > Node.js

1 - About

Express is a Web Framework based on Node (ie javascript)

Advertising

3 - Sample app

  • Install express
npm install express 
  • Javascript
app.js
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

4 - 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
Advertising

5 - Routing

6 - Reload

backend development server that will give you hot-redeploy

npm i nodemon -g

7 - Documentation / Reference

web/javascript/node/express.txt · Last modified: 2019/03/18 11:09 by gerardnico