{"id":29449814,"url":"https://github.com/praths71018/nasa-apis","last_synced_at":"2025-09-08T18:34:01.971Z","repository":{"id":302564831,"uuid":"1012424798","full_name":"praths71018/NASA-APIs","owner":"praths71018","description":"A completely deployed MERN webapp which uses APIs from https://api.nasa.gov/ to retrieve data and if already retrieved its taken from mongodb","archived":false,"fork":false,"pushed_at":"2025-07-04T08:56:28.000Z","size":242,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-13T20:21:21.475Z","etag":null,"topics":["astronomy","axios","express","mars-rover","mern","mern-stack","mongodb","mongoose","nasa-api","react"],"latest_commit_sha":null,"homepage":"https://nasa-apis-webapp.onrender.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/praths71018.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-02T10:07:17.000Z","updated_at":"2025-07-04T06:29:45.000Z","dependencies_parsed_at":"2025-07-03T04:32:54.638Z","dependency_job_id":"27f6b61e-3293-4759-9781-32d4d9c5234a","html_url":"https://github.com/praths71018/NASA-APIs","commit_stats":null,"previous_names":["praths71018/nasa-apis"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/praths71018/NASA-APIs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praths71018%2FNASA-APIs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praths71018%2FNASA-APIs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praths71018%2FNASA-APIs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praths71018%2FNASA-APIs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/praths71018","download_url":"https://codeload.github.com/praths71018/NASA-APIs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praths71018%2FNASA-APIs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274229373,"owners_count":25245188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astronomy","axios","express","mars-rover","mern","mern-stack","mongodb","mongoose","nasa-api","react"],"created_at":"2025-07-13T20:12:02.821Z","updated_at":"2025-09-08T18:34:01.960Z","avatar_url":"https://github.com/praths71018.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Creating a MongoDB database in cloud \n\n### 🌐 1. **Create a MongoDB Atlas Account**\n\n* Go to: [https://www.mongodb.com/cloud/atlas](https://www.mongodb.com/cloud/atlas)\n* Sign up (free tier is enough)\n\n---\n\n### ☁️ 2. **Create a Free Cluster**\n\n* Choose the free **M0** shared cluster\n* Select a cloud provider (AWS is default) and region close to your users\n* Name your cluster (or leave default)\n\n---\n\n### 🧑‍💼 3. **Create a Database User**\n\n* In the **Database Access** tab:\n\n  * Click **\"Add Database User\"**\n  * Choose a **username/password** (e.g. `mern_user` / `mern_pass123`)\n  * Set role: **Read and write to any database**\n\n✅ Save these credentials securely.\n\n---\n\n### 🔓 4. **Whitelist Your IP**\n\n* In the **Network Access** tab:\n\n  * Click **“Add IP Address”**\n  * Choose **“Allow Access from Anywhere”** (`0.0.0.0/0`) for dev\n  * (Use your IP only in prod for better security)\n\n---\n\n### 🔌 5. **Get the Connection URI**\n\n* In **Database → Connect → Drivers → Node.js**, copy the connection string:\n\nIt will look like this:\n\n```\nmongodb+srv://mern_user:mern_pass123@cluster0.abcde.mongodb.net/mars-photos?retryWrites=true\u0026w=majority\n```\n\n---\n\n### ⚙️ 6. **Use in Your Backend**\n\n#### 🔐 Set in `.env` (in your `/server` folder):\n\n```env\nMONGO_URI=mongodb+srv://mern_user:mern_pass123@cluster0.abcde.mongodb.net/mars-photos?retryWrites=true\u0026w=majority\n```\n\n#### 🔌 In `server.js`:\n\n```js\nrequire('dotenv').config();\n\nmongoose.connect(process.env.MONGO_URI).then(() =\u003e {\n  console.log('✅ Connected to MongoDB Atlas');\n}).catch(err =\u003e {\n  console.error('❌ MongoDB connection error:', err.message);\n});\n```\n\n---\n\n### 🧪 7. **Test the App**\n\n* Restart backend: `node server.js`\n* Watch logs for:\n\n  ```\n  ✅ Connected to MongoDB Atlas\n  ```\n\nYour app now stores and retrieves data from **MongoDB in the cloud** 🎉\n\n---\n\n## Deploying on Render\n\nReferred from : [How To Deploy Full Stack React App For Free | Deploy MERN Stack Project In 10 Minutes](https://www.youtube.com/watch?v=cVEOhgPziO8)\n\n### 🔹 **1. Push your full repo to GitHub**\n\n* Your frontend and backend should be in one repo like above.\n* Make sure the root `.gitignore` includes `.env*`.\n\n---\n\n### 🔹 **2. Deploy Backend (Express) on Render**\n\n1. Go to [https://render.com](https://render.com) and sign in\n\n2. Click **“New → Web Service”**\n\n3. Connect your GitHub repo\n\n4. Choose the **`server/`** folder path in the repo\n\n5. Set:\n\n   * **Environment**: Node\n   * **Build Command**: `npm install`\n   * **Start Command**: `node server.js` *(or whatever runs your backend)*\n\n6. Add environment variables:\n\n   * `PORT` = `10000` or leave blank (Render auto assigns)\n   * `MONGO_URI`, `SENTRY_DSN`, `NASA_API_KEY`, etc.\n\n7. Click **Create Web Service**\n\n👉 After deploy, note the backend URL:\n`https://\u003cyour-backend-name\u003e.onrender.com`\n\n---\n\n### 🔹 **3. Deploy Frontend (React) on Render**\n\n1. Go back to [Render](https://render.com)\n\n2. Click **“New → Static Site”**\n\n3. Select the same repo but **set Root Directory = `client/`**\n\n4. Set:\n\n   * **Build Command**: `npm install; npm run build`\n   * **Publish Directory**: `build`\n\n5. Add this environment variable:\n\n   ```\n   REACT_APP_SERVER_URL=https://\u003cyour-backend-name\u003e.onrender.com/api\n   ```\n\n6. Click **Create Static Site**\n\n👉 You’ll get a frontend URL like:\n`https://\u003cyour-webapp-name\u003e.onrender.com`\n\n7. In Server Cors , replace origin with frontend URL\n\n    ```\n    app.use(cors({\n        origin: process.env.FRONTEND_URL || 'http://localhost:3000', // Use environment variable or default to localhost\n        methods: ['GET', 'POST'],\n        allowedHeaders: ['Content-Type'],\n    }));\n    ```\n\n---\n\n### 🔐 Notes on `.env` and API URL\n\n* In **React**, all env vars must start with `REACT_APP_`\n* In your frontend, use:\n\n  ```js\n  axios.get(`${process.env.REACT_APP_SERVER_URL}/photos/search`)\n  ```\n* In Render’s settings, set correct values in **Environment → Add Environment Variable**\n\n---\n\n## 🧪 Test Deployment\n\n1. Open the frontend Render URL\n2. Test your search form — it should hit the backend hosted on Render\n\n---\n\n## Configuring Sentry for the Webapp\n\nHere's how you can add **Sentry** to your **MERN stack webapp** for **error tracking**:\n\n---\n\n### ✅ Step 1: Sign Up and Create Project on Sentry\n\n1. Go to [https://sentry.io](https://sentry.io)\n2. Create an account\n3. Click “**Create Project**”\n4. Choose **React** for frontend and **Node.js** for backend\n5. Copy the DSN (Data Source Name) for each — you’ll use this in `.env`\n\n---\n\n### ✅ Step 2: Add Sentry to Your **Frontend (React)**\n\n#### 🔧 1. Install SDK:\n\n```bash\nnpm install @sentry/react @sentry/tracing\n```\n\n#### 🔧 2. Initialize Sentry in `src/index.js` or `src/main.jsx`:\n\n```js\nimport * as Sentry from \"@sentry/react\";\nimport { BrowserTracing } from \"@sentry/tracing\";\n\nSentry.init({\n  dsn: process.env.REACT_APP_SENTRY_DSN, // store in .env\n  integrations: [new BrowserTracing()],\n  tracesSampleRate: 1.0,\n});\n```\n\n#### 🔧 3. Handle errors manually (optional):\n\n```js\ntry {\n  // something buggy\n} catch (e) {\n  Sentry.captureException(e);\n}\n```\n\n---\n\n### ✅ Step 3: Add Sentry to Your **Backend (Express)**\n\n#### 🔧 1. Install SDK:\n\n```bash\nnpm install @sentry/node\n```\n\n#### 🔧 2. Add to `server.js` (or wherever Express is initialized):\n\n```js\nconst Sentry = require('@sentry/node');\nSentry.init({\n  dsn: process.env.SENTRY_DSN, // server-side DSN in .env\n});\n\n// Request handler must be first\n\n// Your routes here...\n\n// Example Error Endpoint\napp.get(\"/debug-sentry\", function mainHandler(req, res) {\n  throw new Error(\"My first Sentry error!\");\n});\n\n// ✅ 8. Error Handler (must come *after* routes)\nSentry.setupExpressErrorHandler(app);\n\n#### 🔧 3. Manually log errors if needed:\n\n```js\ntry {\n  // something wrong\n} catch (err) {\n  Sentry.captureException(err);\n}\n```\n\n---\n\n### ✅ Step 4: Set up `.env` Files\n\n#### `.env.production.local` in React:\n\n```\nREACT_APP_SENTRY_DSN=https://your-frontend-dsn@o0.ingest.sentry.io/0\n```\n\n#### `.env` in Backend:\n\n```\nSENTRY_DSN=https://your-backend-dsn@o0.ingest.sentry.io/0\n```\n\n---\n\n### ✅ Step 5: Deploy and Test\n\n1. Deploy your app\n2. Trigger an error (like divide by 0 or `undefined.map()`)\n3. Go to Sentry dashboard — you'll see logs with **stack trace, user agent, route**, etc.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpraths71018%2Fnasa-apis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpraths71018%2Fnasa-apis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpraths71018%2Fnasa-apis/lists"}