Skip to content

Repository files navigation

Rollercoasters API system

This system is an API Project for “Roller Coaster System”.

Built with

TypeScript | Node.js | Express.js | Redis | Zod | Pino

Requirements

  • Docker
  • Node.js 22.x
  • Redis

Instalatation

  1. Clone the repo:
    git clone https://github.com/hubertkozik/rollercoasters.git
  2. Go into the folder:
    cd rollercoasters
  3. Create two environment files:
  • .env.dev
    PORT=3050
    ENV=dev
    REDIS_HOST=localhost
    REDIS_PORT=6379
  • env.prod
    PORT=3051
    ENV=prod
    REDIS_HOST=localhost
    REDIS_PORT=6379
  1. Install packages:
    #npm
    npm i
    
    #pnpm
    pnpm i

Development

#npm
npm run dev

#pnpm
pnpm dev

Build

#npm
npm run build

#pnpm
pnpm build

Docker

Use Docker Compose to manage production and development environments. Ensure the .env files are correctly configured before executing the following command.

Production Port: 3051 Development Port: 3050

docker compose up

API Documentation

  • Ping

GET /api/ping

Check if the API server is operational.

Request example:

localhost:3050/api/ping

Response example:

200 OK
pong
  • Create a new coaster

POST /api/coasters

Create a new roller coaster with specified parameters.

Request:

localhost:3050/api/coaster

Request body example:

{ 
    "liczba_personelu": 16,
    "liczba_klientow": 60000,
    "dl_trasy": 18000,
    "godziny_od": "8:00",
    "godziny_do": "16:00"
}

Response example:

201 Created
{
    "id": "deuHCba_En9nNtSymj6sx"
}
  • Update an existing coaster

PUT /api/coasters/:coasterId

Modify an existing roller coaster's parameters.

Request example:

localhost:3050/api/coasters/deuHCba_En9nNtSymj6sx

Request body example:

{ 
    "liczba_personelu": 12,
    "liczba_klientow": 3000,
    "godziny_od": "10:00",
    "godziny_do": "18:00"
}

Response example:

200 OK
  • Add a wagon to an existing coaster

POST /api/coasters/:coasterId/wagons

Add a new wagon to an existing roller coaster.

Request example:

localhost:3050/api/coasters/deuHCba_En9nNtSymj6sx/wagons

Request body example:

{
    "ilosc_miejsc": 64,
    "predkosc_wagonu": 10.2
}

Response:

201 Created
{
    "id": "G5_TriARPCCYVPxV8hKkm"
}
  • Add a wagon to an existing coaster

DELETE /api/coasters/:coasterId/wagons/:wagonId

Remove a specific wagon from a specific roller coaster.

Request example:

localhost:3050/api/coasters/deuHCba_En9nNtSymj6sx/wagons/G5_TriARPCCYVPxV8hKkm

Response example:

200 OK

Data Specifications

API Parameters

Parameter Description Unit
liczba_personelu Number of staff members managing the coaster People
liczba_klientow Daily client capacity People
dl_trasy Track length Meters
godziny_od Start of operations 24-hour format
godziny_do End of operations 24-hour format
ilosc_miejsc Wagon capacity Seats
predkosc_wagonu Wagon velocity Meters/second

URL Path Parameters

Parameter Description
coasterId Unique identifier for a roller coaster
wagonId Unique identifier for a wagon

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages