nasa-udacity

所属分类:交通/航空行业
开发工具:JavaScript
文件大小:252KB
下载次数:0
上传日期:2023-01-04 07:36:58
上 传 者sh-1993
说明:  Udacity远程配对编程项目
(A Udacity remote pair programming project)

文件列表:
.eslintrc.json (510, 2019-09-26)
.firebaserc (54, 2019-09-26)
firebase.json (235, 2019-09-26)
package.json (1171, 2019-09-26)
public (0, 2019-09-26)
public\favicon.ico (3870, 2019-09-26)
public\index.html (507, 2019-09-26)
public\manifest.json (287, 2019-09-26)
public\nasa.png (32412, 2019-09-26)
src (0, 2019-09-26)
src\actions (0, 2019-09-26)
src\actions\index.js (528, 2019-09-26)
src\actions\types.js (78, 2019-09-26)
src\assets (0, 2019-09-26)
src\assets\logo.svg (2671, 2019-09-26)
src\assets\nasa.png (32412, 2019-09-26)
src\components (0, 2019-09-26)
src\components\App.css (156, 2019-09-26)
src\components\App.js (1051, 2019-09-26)
src\components\Detail.js (1645, 2019-09-26)
src\components\Home.js (1561, 2019-09-26)
src\components\MediaItem.js (1239, 2019-09-26)
src\components\Navigation.js (478, 2019-09-26)
src\fire.js (414, 2019-09-26)
src\index.css (63, 2019-09-26)
src\index.js (641, 2019-09-26)
src\reducers (0, 2019-09-26)
src\reducers\imageReducer.js (298, 2019-09-26)
src\reducers\index.js (146, 2019-09-26)
src\registerServiceWorker.js (2157, 2019-09-26)
src\services (0, 2019-09-26)
src\services\index.js (343, 2019-09-26)
yarn.lock (464069, 2019-09-26)

# NASA Udacity Our project repository for the `Google Mobile Web Challenge 2017`. > Pairing on Monday 10am CET We decided to start a new project, in order to solidify our knowledge about Progressive Web Apps and Service Workers and decided to use these core technologies for our project: - Firebase (Backend & Database) - ReactJS (Front End) - Service Workers - crontab (cron job) ## Installation instructions ```bash git clone git@github.com:alexanderluna/nasa-udacity.git cd nasa-udacity yarn install yarn start ``` Please read the next section on crontab. ## Crontab The reason we have to use Crontab is because we are using Firebase and the Spark plan (free tier) only allows for Google API requests not third party ones. We are using NASA's API to get the `Image of Day` thus I created a small node app that gets once a day the `Image of the Day` and posts it via the Command line to our Firebase Database. The node app itself requires only 1 module: `request-json`: ``` javascript let request = require('request-json'); let nasa = request.createClient('https://api.nasa.gov/planetary/'); let firebase = request.createClient('https://nasa-udacity.firebaseio.com/'); nasa.get('apod?api_key=DEMO_KEY', (err, res, body) => { let copyright = body.copyright ? body.copyright : 'Public Domain'; let data = { date: body.date, explanation: body.explanation, media_type: body.media_type, title: body.title, url: body.url, copyright: copyright }; firebase.post('Images.json', data, (err, res, body) => { if (err) return console.log("Error posting new image"); console.log("Saved Images successfully"); }); }); ``` As you can see, it does a `GET` request to NASA's API, parses the response and creates a `POST` request to our database effectively bypassing our problem.

近期下载者

相关文件


收藏者