Skip to content

Commit

Permalink
docs(session-5): api with express
Browse files Browse the repository at this point in the history
  • Loading branch information
92bondstreet committed Mar 7, 2021
1 parent fec1ba4 commit 8a7b24a
Show file tree
Hide file tree
Showing 8 changed files with 561 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ With [javascript-empire](https://github.com/92bondstreet/javascript-empire/tree/
| 2 | [Interact data with JavaScript, HTML and CSS in the browser again](./workshops/2-interact-js-css.md) | 25th and 26th January 2021
| 3 | [Scrape data with Node.js](./workshops/3-scrape-node.md) | 1st and 8th February 2021
| 4 | [Save data in a Database with MongoDB](./workshops/4-store-mongodb.md) | 1st March 2021
| 5 | Build an api with Express to request data | 8th March 2021
| 5 | [Build an api with Express to request data](./workshops/5-api-express.md) | 8th March 2021
| 6 | Test your code with Jest | 15th March 2021
| 7 | Deploy in production with Vercel | 22th March 2021
| 8 | Render data with React | April extra mile.
Expand Down
22 changes: 22 additions & 0 deletions server/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const cors = require('cors');
const express = require('express');
const helmet = require('helmet');

const PORT = 8092;

const app = express();

module.exports = app;

app.use(require('body-parser').json());
app.use(cors());
app.use(helmet());

app.options('*', cors());

app.get('/', (request, response) => {
response.send({'ack': true});
});

app.listen(PORT);
console.log(`📡 Running on port ${PORT}`);
3 changes: 3 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"dependencies": {
"axios": "^0.21.1",
"cheerio": "^1.0.0-rc.5",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"helmet": "^4.4.1",
"mongodb": "^3.6.4",
"parse-domain": "^3.0.3",
"require-all": "^3.0.0",
Expand Down
Loading

0 comments on commit 8a7b24a

Please sign in to comment.