In here, you can see and test the REST API of rocket launches from FutureSpace Inc.
To clone and run the application, you will need to have Git, Docker Engine and Docker-compose installed on your machine. With all programs installed, run the following command lines:
# Pull the postgres docker image
$ docker pull postgres:13.4-alpine
# Pull the node docker image
$ docker pull node:14-alpine
# Clone this repository
$ git clone https://github.com/nickcarva/future-space-rest-api.git
# Access the repository
$ cd future-space-rest-api
Before start the server, you must copy .env-sample
to .env
and fill the environment variables based your data to access the pg database and the API.
# Run application
$ docker-compose up --build -d
# Run all migrations (it's necessary just once)
$ docker exec future-space-rest-api_server_1 npm run typeorm migration:run
# Stop application
$ docker-compose down
So that you can access all the REST API endpoints, you must put an API key authorization header in the request. This API Key is registered in the .env
file (just for a representation of security).
The header key is 'api-key'.
GET /
: Return the message "REST Back-end Challenge 20201209 Running"
PUT /launchers/:launch_id
: Update a launch data
DELETE /launchers/:launch_id
: Delete a launch
GET /launchers/:launch_id
: Show a launch data
GET /launchers
: List all launches
So that we can have all launches updated, a schedule is set to everyday at 6:30 AM +00 for import all launches from the Space Devs API. When testing this project, you can change the schedule time in src/schedules/LaunchesImporterSchedule.ts
using the node-schedule CRON rules.