Skip to content

Making transport-magic project with items and logs

Notifications You must be signed in to change notification settings

afehid/magic-transport

Repository files navigation

Magic Transporters

Welcome to Magic Transporters, a Node.js application built with NestJS for managing magical transporters and items. This repository contains the backend API service.

Database Diagram

Database Diagram

Table of Contents

Introduction

Magic Transporters is a REST API service designed to manage magical transporters and their associated items. It provides endpoints for CRUD operations on transporters and items, leveraging NestJS with TypeScript.

Features

  • Create, Read, Update, and Delete operations for magic transporters and items.
  • Swagger API documentation.
  • Testing with Jest.

Description

Magic Mover API Operations

Adding a Magic Mover

Description: Adds a new magical mover to the system.

    POST /api/movers
    Creates a new mover with specified details.
    
    Example Request Body:
    
      {
        "energy": 50,
        "weightLimit": 100
      }
    
    
    Example Response:
    
      {
        "id": 123,
        "energy": 50,
        "weightLimit": 100,
      }
    
  

Adding a Magic Item

Description: Adds a new magic item to the system.

    POST /api/items
    Creates a new item with specified details.
    
    Example Request Body:
    
      {
        "name": "Magic Wand",
        "weight": 10,
      }
    
    
    Example Response:
    
      {
        "id": 1,
        "name": "Magic Wand",
        "weight": 10,
      }
    
  

Loading a Magic Mover with Items

Description: Loads items onto a specific magic mover, creating a log of this activity.

    POST /api/movers/:id/load
    Loads items onto the mover specified by :id.
    
    Example Request Body:
    
      {
        "items": [1, 2, 3]  // Array of item IDs to load onto the mover
      }
    
    
    Example Response:
    
      {
        "id": 1,
        "weightLimit": 100,
        "energy": 50,
        "questState": "loading"
      }
    
  

Starting a Mission

Description: Updates the state of a magic mover to indicate it's on a mission, stopping further loading and creating a log of this activity.

    PUT /api/movers/:id/start-mission
    Updates the state of the mover specified by :id to "on a mission".
    
    Example Response:
    
        {
          "id": 1,
          "weightLimit": 100,
          "energy": 50,
          "questState": "onMission"
        }
    
  

Ending a Mission

Description: Unloads all items from a magic mover, creating a log of this activity indicating mission completion.

    PUT /api/movers/:id/end-mission
    Unloads all items from the mover specified by :id, marking the mission as complete.
    
    Example Response:
    
        {
          "id": 1,
          "weightLimit": 100,
          "energy": 50,
          "questState": "done"
        }
    
  

Most Completed Missions

Description: Make a simple list to show completed the most missions (ordered descending).

    GET /api/mission-logs/most-completed
    Example Response:
    
        [
          {
            "moverId": 1,
            "missionCount": "4"
          },
          {
            "moverId": 2,
            "missionCount": "2"
          }
        ]
    
  

Prerequisites

Before you begin, ensure you have the following installed on your development machine:

  • Node.js (v14 or higher)
  • npm (or yarn)
  • MySql (or another compatible relational database)

Getting Started

To get the project up and running on your local machine, follow these steps:

Installation

    git clone https://github.com/afehid/magic-transport.git
    cd magic-transport
    npm install
  

Configuration

Set up your environment variables:

Create a .env file in the root directory based on .env.example.

  PORT=
  USERNAME=
  PASSWORD=
  DATABASE=
  HOST=
  DATABASE_PORT=

  

Usage

Start the application in development mode:

    npm run start:dev
  

The server will start running at http://localhost:3000.

Endpoints

For detailed API documentation, visit the Swagger UI at:

http://localhost:3000/api

Testing

Testing Coverage

Testing Coverage

Run tests using Jest:

    npm test
  

Deployment

For deployment to production, ensure to set appropriate environment variables and configure your server environment accordingly.

About

Making transport-magic project with items and logs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published