feat: add individual resource endpoints by ID#67
Open
AdityaAsopa wants to merge 2 commits intoisro:masterfrom
Open
feat: add individual resource endpoints by ID#67AdityaAsopa wants to merge 2 commits intoisro:masterfrom
AdityaAsopa wants to merge 2 commits intoisro:masterfrom
Conversation
The spacecraft_missions data had deeply inconsistent schemas — mass appeared as 'weight', 'lift-off_mass', 'spacecraft_mass', 'mass_at_lift-off' and 5 other variants; dates ranged from 'April 19, 1975' to '22 October 2008' to '26-05-1999' across 15+ formats; KALPANA-1 had mission_life stored in the 'mission' field as '7 Years'; and TES appeared as a duplicate entry. spacecrafts.json had only id+name for 113 records. launchers.json had only id for 81 records. customer_satellites.json mixed 'GERMANY' with 'Germany' and 'UK' with 'UNITED KINGDOM'. This commit introduces scripts/normalize_data.py — an idempotent pipeline that parses all date formats to ISO 8601, extracts numeric mass_kg and power_watts from free-text fields (handling edge cases like '15 Sq.m Solar Array generating 1360W'), classifies orbits (LEO/SSO/GEO/Lunar/Failed), infers mission status from launch date + mission life, and normalizes country names. The scraper was re-run against isro.gov.in and the fresh data is merged with existing records — no data is lost, only enriched. All 5 data files now have consistent, documented schemas. spacecrafts are enriched with launch date, vehicle, orbit type, and status from missions. Launchers are classified into 8 vehicle families. All API endpoints remain backward-compatible — same URLs, same structure, just cleaner data. API handlers: removed unused 'fs' imports, fixed misleading variable names (customer_satellites.js loaded data into a var called 'launchers'), added Content-Type: application/json headers, and sanitized error responses. Root endpoint now returns a JSON directory of all available endpoints.
Adds /api/:resource/:id endpoints for all five collections: - GET /api/spacecrafts/:id - GET /api/launchers/:id - GET /api/customer_satellites/:id - GET /api/centres/:id - GET /api/spacecraft_missions/:id Returns the matching record directly (not wrapped), 404 if not found, 400 if ID is not a valid integer. No new data added — reads directly from existing normalized JSON files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
/api/:resource/:idendpoints for all five collections, following standard REST conventions.New endpoints
GET /api/spacecrafts/:id/api/spacecrafts/1→ AryabhataGET /api/launchers/:id/api/launchers/5→ PSLV-C1GET /api/customer_satellites/:id/api/customer_satellites/3GET /api/centres/:id/api/centres/2GET /api/spacecraft_missions/:id/api/spacecraft_missions/10Response
404with{ "error": "Not found" }if ID doesn't exist400with{ "error": "Invalid ID" }if ID is not a valid integerImplementation
Uses Vercel's
[id].jsdynamic route convention — one file per collection underapi/<collection>/[id].js. No new dependencies, no new data, no changes to existing collection endpoints.Backward compatibility
Existing
/api/spacecrafts,/api/launchers, etc. endpoints are completely unchanged.Test plan
/api/spacecrafts/1returns Aryabhata record/api/spacecrafts/999returns 404/api/spacecrafts/abcreturns 400