Skip to content

Instantly share code, notes, and snippets.

@Lio-code
Created June 2, 2020 19:10
Show Gist options
  • Select an option

  • Save Lio-code/a6196df3ef69fbae6d0c9c794f7b4f62 to your computer and use it in GitHub Desktop.

Select an option

Save Lio-code/a6196df3ef69fbae6d0c9c794f7b4f62 to your computer and use it in GitHub Desktop.
Lionel - Express 1 - Découverte d'Express
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (request, response) => {
response.send('Bienvenue sur Express');
});
app.get('/api/movies', (request, response) => {
response.send('Récupération de tous les films');
});
app.get(`/api/movies/:id`, (request, response) => {
const id = request.params.id;
response.json({ id: id });
});
app.get(`/api/employee`, (request, response) => {
const name = request.query.name;
response.status(404).send(`Impossible de récupérer l'employé ${name}`)
});
app.get('/api/employee', (request, response) => {
response.status(304).end();
});
app.listen(port, (err) => {
if (err) {
throw new Error('Something bad happened...');
}
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