Skip to content

Latest commit

 

History

History
87 lines (62 loc) · 2.29 KB

File metadata and controls

87 lines (62 loc) · 2.29 KB

Todo API

Todo API is a simple RESTful service for managing a to-do list, allowing users to create, read, update, and delete tasks.

Prerequisites

Quick Start

  1. Clone the repository:

    git clone https://github.com/matheusgalvao1/todo-api.git
    cd todo-api
  2. Build and start the application with Docker Compose:

    docker-compose up --build -d
  3. The API will be available at http://localhost:8000.

Authentication Methods

The API's authentication is configured through auth_config.yml in the root directory:

  1. No Authentication (none):

    auth:
      method: none

    All endpoints will be public.

  2. API Key Authentication (api_key):

    auth:
      method: api_key
      api_key: your-secure-api-key

    Clients must include the API key in the X-API-Key header.

  3. JWT Authentication (jwt):

    auth:
      method: jwt
      secret: your-jwt-secret

    Clients must obtain a JWT token via login/signup and include it in the Authorization: Bearer <token> header.

  4. Session Authentication (session):

    auth:
      method: session
      secret: your-session-secret

    Uses browser sessions for authentication.

Initial Data

The project comes with initial data, seeded at startup:

  • Todos: initial_todos.json
  • Users: initial_users.json

Running the API

Simply run:

python app/main.py

The API will read the configuration from auth_config.yml. If the file doesn't exist, it will default to no authentication.

Sidecar Usage

The application is containerized and exposes port 8000, making it suitable for use as a sidecar in various deployment scenarios.

The Docker container exposes port 8000, allowing the API to be accessed from other containers or services in the same network. In order to enable it in the task, you need to add the following to the task configuration:

  • For PR testing: ghcr.io/codesignal/learn_todo-api:<pr-number>
    • Example: ghcr.io/codesignal/learn_todo-api:pr-8
  • For main branch: ghcr.io/codesignal/learn_todo-api:latest

The sidecar can be used in base tasks and other containerized environments where you need a todo API service.