Skip to content

Instantly share code, notes, and snippets.

@AmauryLugdu
Created November 20, 2019 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmauryLugdu/9d3c5666ca1f5173a4c0347b13b76f2f to your computer and use it in GitHub Desktop.
Save AmauryLugdu/9d3c5666ca1f5173a4c0347b13b76f2f to your computer and use it in GitHub Desktop.
Express 1 - Discover Express
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