Skip to content

Commit

Permalink
Pass through a date param
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Butz committed Dec 5, 2019
1 parent c7bf4c3 commit 0677ddf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"morgan": "~1.9.1"
},
"engines": {
"node": ">=13.2.0"
"node": "13.1.0"
}
}
11 changes: 10 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ const express = require('express');
const client = require('../services/nasa.client');
const router = express.Router();

function extractDate(date) {
if (date === undefined) {
return 'today';
}

return date;
}

function index(nasaApiKey) {
router.get('/', async function(req, res, next) {
const desc = await client.getApodDesc(nasaApiKey)
const date = extractDate(req.query.date);
const desc = await client.getApodDesc(nasaApiKey, date);

await res.json({ desc });
});
Expand Down

0 comments on commit 0677ddf

Please sign in to comment.