vite

npm create vite@latest

npm i

npm run dev



debug

 le module debug est un must ! 

https://www.npmjs.com/package/debug


La définition des espace de noms dépendra de votre terminal : 

cmd

set DEBUG=baseRange:arg,http & node app.js

 

git bash 

Si votre terminal est git bash lancer : 

DEBUG=baseRange:arg,http node app.js

 

PowerShell

Si votre terminal est PowerShell lancer : 

$env:DEBUG='baseRange:arg,http' ; node app.js


Github page.

 Création d'un déploiement. 



Autre idée, cloner tout simplement la branche master dans la branche gh-pages. that's it.


my-json-server


Créez son propre server JSON !

https://jsonplaceholder.typicode.com/


https://my-json-server.typicode.com/dupontdenis/myJsonServer

En action : https://github.com/dupontdenis/myJsonServer.git

npx


>npx lite-server

It will create a local web server and open your app in a browser.

Extension Rest Client

Créer un fichier app.js

const express = require('express');
const bodyParser = require('body-parser');
const app = express()

app.use(bodyParser.json());


const port = 3000

sayhello = function(pers){
    return `hello ${pers}`
}

app.post('/', (req, res) => {
  res.send(sayhello(req.body && req.body.pers || 'hi'))
})


app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)}) 

Mettre en place l'application :
  • npm init -y
  • npm install express
Dans un terminal lancez l'application :
  • node app.js


Ajouter l'extension Rest API.

Créer un fichier api.http

POST http://localhost:3000
Content-Type: application/json

{"pers":"denis"}

En cliquant sur le lien Send Request (pas sur http://localhost:3000), on obtient la réponse suivante.



Plus besoin de Postman pour ce type de test.


Autre exemple avec une authentification