Skip to content

Instantly share code, notes, and snippets.

@dragonslayer77
Created May 21, 2019 08:13
Show Gist options
  • Save dragonslayer77/fd990b8850752ea6ec377fa082585776 to your computer and use it in GitHub Desktop.
Save dragonslayer77/fd990b8850752ea6ec377fa082585776 to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
const port = 3000;
app.get('/api/movies', (request, response) => {
response.send('All Films');
});
app.get('/api/movies/:id', (request, response) => {
response.json({id: request.params.id});
});
app.get('/api/employee', (request, response)=> {
const name = request.query.name;
if (name) {
response.status(404).send('Unable to retrieve employee ' + name);
} else {
response.sendStatus(304);
}
});
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