spacetalk
Version:
Script that returns info from queryable types from SpaceX API
43 lines (23 loc) • 1.97 kB
Markdown
# Spacetalk
A Node CLI for SpaceX.
## Usage
Use nvm to install Node 14.16.0. Follow instructions [here](https://github.com/nvm-sh/nvm) per your machine.
`npm install spacetalk -g`
`man spacetalk`
`spacetalk get all capsules`
`spacetalk get rocket 5e9d0d95eda69955f709d1eb`
## FAQ
This package has not been tested outside Mac OS and Debian with Node 14.16.0.
**Q: `node ./cli.js` doesn't work.**
**A**: If you are developing and have permission issues when running node ./cli.js, ensure to give file execution permission: `chmod +x cli.js`. For regular usage, you should not have to do that.
**Q: `npm install space -g` doesn't work.**
**A**. On Linux and other machines, if there's a permission denied error after running `npm install spacetalk -g`, you'll want to [reinstall npm with a node version manager](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally).
**Q: `man spacespace` doesn't work.**
**A**: To get `man spacetalk` to work on Linux, install man with `apt install man-db`.
## Assumptions
1. Could be extended to support a web service.
2. Uses low-level language APIs or performant libs.
3. Should it be a bash script or an npm package. Why not both? Npm lets us create modules that [run as bash commands](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#bin). It even supports roff files (man pages).
## Decisions
Uses [got](https://github.com/sindresorhus/got) for http library. I looked at npmtrends and compared http request libs. [This](https://www.npmtrends.com/got-vs-axios-vs-superagent-vs-node-fetch-vs-https) was the comparison I ran. But then I wondered, which one is faster? I picked `got` and `https` to fetch data from `/api.spacexdata.com/v4/capsules`. Results were 3.387ms and 40.202ms. Decision has been to go with `got` also for its async functionality and developer friendliness.
Uses basic `npm` best practices so that the UI is accessible via the CLI.