hernanijr / planet-ages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Planet Ages

Features

  • Multi-Planet Age Calculator: Calculate a person's age on different planets based on the provided seconds and planetary information.

Prerequisites

Before you begin, ensure you have the following installed:

Getting Started

To run the application locally, follow these steps:

  1. Clone this repository:
 git clone https://github.com/hernanijr/planet-ages.git
 cd planet-ages
  1. 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
}
  1. Running the Tests
docker compose up test

Stop the Container

docker-compose down

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

License

Nest is MIT licensed.

About


Languages

Language:TypeScript 90.7%Language:JavaScript 7.7%Language:Dockerfile 1.6%