Skip to content

This ToDo API was made in the Distributed and Parallel systems course at HS-Esslingen.

Notifications You must be signed in to change notification settings

FreakeyPlays/vs-lab-backend

Repository files navigation

HSE Logo

A ToDo-API build with NestJS in the Distributed and Parallel Systems Course at HS-Esslingen.

πŸ“Œ - Description

This NestJS Application provides an REST-API to manage ToDos.
All CRUD Function are provided and Documented using Swagger (Available under /doc).

🐳 - Docker Installation

  1. Pull the Docker Image
docker pull ghcr.io/freakeyplays/vs-lab-backend:<version>
  1. Run the Docker Image
# Use Deafault Environment Variables
docker run -p 8080:3000 ghcr.io/freakeyplays/vs-lab-backend:<version>

# Provide Environment Variables via the CL
docker run -e SERVER_PORT=5000 ... -p 8080:$SERVER_PORT ghcr.io/freakeyplays/vs-lab-backend:<version>

# Provide Envrionment Variables via .env File
docker run --env-file -p 8080:$SERVER_PORT ghcr.io/freakeyplays/vs-lab-backend:<version>

βš™οΈ - Development Installation

  1. Clone the Repository
git clone https://github.com/FreakeyPlays/vs-lab-backend.git
  1. Install Dependencies
npm install
  1. Install a Local Postgres Database or Provide a connection via the Environment Variables

  2. Run the Application in Development Mode

npm run start:dev
  1. Access the Application at localhost:3000

🧰 - Environment Variables

Name Type Description Default
SERVER_PORT number The Port to access the Application.
When using Docker this is the Inside Port
3000
POSTGRES_HOST string The Host where the Database is served.
Example: www.example.com
localhost
POSTGRES_PORT number The Port of where the Database is served. 5432
POSTGRES_USER string The Username to access Database. postgres
POSTGRES_PASSWORD string The Password to access the Database. password
POSTGRES_DB_NAME string The Name of the Database. postgres

⛓️ - API

πŸ”— - POST /todos

πŸ“₯ - Request

curl -X 'POST' \
  '${BASE_URL}/todos' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "todo": "string",
  "priority": 2
}'

πŸ“€ - Response

{
  "todo": String,
  "priority": Number
}

πŸ”— - GET /todos

πŸ“₯ - Request

curl -X 'GET' \
  '${BASE_URL}/todos' \
  -H 'accept: */*'

πŸ“€ - Response

[
  {
    "todo": String,
    "priority": Number
  },
  ...
]

πŸ”— - PUT /todos

πŸ“₯ - Request

curl -X 'PUT' \
  '${BASE_URL}/todos' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "todo": "string",
  "priority": 0
}'

πŸ“€ - Response

{
  "generatedMaps": Array,
  "raw": Array,
  "affected": Number
}

πŸ”— - DELETE /todos

πŸ“₯ - Request

curl -X 'DELETE' \
  '${BASE_URL}/todos' \
  -H 'accept: */*'

πŸ“€ - Response

{
  "raw": Array,
  "affected": Number
}

πŸ”— - POST /todos/{todo}

πŸ“₯ - Request

curl -X 'DELETE' \
  '${BASE_URL}/todos/${todo}' \
  -H 'accept: */*'

πŸ“€ - Response

{
  "raw": Array,
  "affected": Number
}

πŸ”— - GET /todos/{todo}

πŸ“₯ - Request

curl -X 'DELETE' \
  '${BASE_URL}/todos/${todo}' \
  -H 'accept: */*'

πŸ“€ - Response

{
  "todo": String,
  "priority": Number
}

πŸ”— - DELETE /todos/{todo}

πŸ“₯ - Request

curl -X 'DELETE' \
  '${BASE_URL}/todos/${todo}' \
  -H 'accept: */*'

πŸ“€ - Response

{
  "raw": Array,
  "affected": Number
}