NASA APOD
Fetching the APOD API data from NASA.
Local Setup
Clone the repository
git clone <SSH/HTTPS link>
Change directory
cd NASA-APOD
Create environent (.env
) file
touch .env
Add port to .env
file
echo PORT=3000 >> .env
#or manually type in port
PORT=3000
Install npm dependencies
npm install
Run build compilation step
npm run build
Run server
npm run server
API Key
You can use the demo key if you don't want to sign up for a developer key.
In index.ts
, change
const api_key: string = config.API_KEY;
to
const api_key: string = 'DEMO_KEY';
Otherwise, create a key.ts
file containing an object with your developer key. Note that this is unsafe, and it is preferred that you store it on the server-side using an environment (.env
) file instead. If you are using this method, make sure to ignore the key.ts
file in your .gitignore
.
cd NASA-APOD/src/api
touch key.ts
//key.ts
const config = {
API_KEY: 'your developer api key'
};
export default config;
Import your key in index.ts
import config from './key.js'