Skip to content

REST API of rocket launches from FutureSpace Inc. - Node.js

Notifications You must be signed in to change notification settings

nickcarva/future-space-rest-api

Repository files navigation


FutureSpace REST API


In here, you can see and test the REST API of rocket launches from FutureSpace Inc.

🚀 Getting started

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

🚫 How to stop the containers and the application

# Stop application 
$ docker-compose down

🔑 API Key

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'.

api-key-representation

📍 REST API

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

⏱ Launches imports schedule

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.

Releases

No releases published

Packages

No packages published

Languages