- Multi-Planet Age Calculator: Calculate a person's age on different planets based on the provided seconds and planetary information.
Before you begin, ensure you have the following installed:
To run the application locally, follow these steps:
- Clone this repository:
git clone https://github.com/hernanijr/planet-ages.git
cd planet-ages
- Running the Application
docker compose up app
The API should start at http://localhost:3000
.
Planetary Age Calculation To calculate a person's age on different planets, use the following endpoint:
- Endpoint:
/calculate-age
- Method:
GET
- URL Params:
seconds=[number]&type=[string]
- seconds: Number of seconds
- type: Planet type (e.g., "Earth," "Venus," etc.)
- Success Response:
${number} Planet-years-old
- Error Response:
{ message: 'Invalid input', error: 'Please provide valid seconds and planet type.', statusCode: 400 }
Example:
curl http://localhost:3000/calculate-age?seconds=2500000000&type=Venus
Response:
{
48.74 Venus-years-old
}
- Running the Tests
docker compose up test
docker-compose down
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Nest is MIT licensed.