Created
November 20, 2019 10:07
-
-
Save AmauryLugdu/9d3c5666ca1f5173a4c0347b13b76f2f to your computer and use it in GitHub Desktop.
Express 1 - Discover Express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get("/api/movies", (req, res) => { | |
res.send("Récupère tout les films"); | |
}); | |
app.get("/api/movies/:id", (req, res) => { | |
res.json({ id: req.params.id }); | |
}); | |
app.get("/api/employé", (req, res) => { | |
res.sendStatus(304); | |
}); | |
app.get("/api/employé", (req, res) => { | |
res.status(404).send(`L'employé ${req.query.name} est introuvable`); | |
}); | |
app.listen(port, err => { | |
if (err) { | |
throw new Error("Une erreur vient de se produire..."); | |
} | |
console.log(`Server is listening on ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment