openapi: 3.0.0
info:
  title: Uptime Sentinel API
  description: API for network monitoring and status page management.
  version: 1.0.0
servers:
  - url: http://localhost:3000/api
    description: Local Development
  - url: http://localhost:3090/api
    description: Docker Production

paths:
  /health:
    get:
      summary: System Health Check
      description: Returns the health status of the application and database connection.
      responses:
        "200":
          description: System is healthy
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: healthy
                  database:
                    type: string
                    example: connected
                  timestamp:
                    type: string

  /monitors:
    get:
      summary: List Monitors
      description: Retrieve a paginated list of monitors with optional filtering.
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
        - in: query
          name: limit
          schema:
            type: integer
            default: 10
        - in: query
          name: search
          schema:
            type: string
        - in: query
          name: type
          schema:
            type: string
            enum: [http, ping, tcp, deleted]
      responses:
        "200":
          description: A list of monitors
          content:
            application/json:
              schema:
                type: object
                properties:
                  monitors:
                    type: array
                    items:
                      $ref: "#/components/schemas/Monitor"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"

    post:
      summary: Create Monitor
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateMonitorInput"
      responses:
        "201":
          description: Monitor created successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Monitor"

  /monitors/{id}:
    get:
      summary: Get Monitor Details
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Monitor details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Monitor"

    patch:
      summary: Update Monitor
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateMonitorInput"
      responses:
        "200":
          description: Monitor updated

    delete:
      summary: Delete Monitor
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Monitor deleted (soft delete)

components:
  schemas:
    Monitor:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        url:
          type: string
        type:
          type: string
          enum: [http, https, ping, tcp, dns]
        status:
          type: string
          enum: [up, down, maintenance]
        active:
          type: boolean
        intervalSeconds:
          type: integer

    CreateMonitorInput:
      type: object
      required:
        - name
        - type
      properties:
        name:
          type: string
        url:
          type: string
        type:
          type: string
          enum: [http, https, ping, tcp]
        intervalSeconds:
          type: integer
          default: 60
        active:
          type: boolean
          default: true

    PaginationMeta:
      type: object
      properties:
        total:
          type: integer
        page:
          type: integer
        limit:
          type: integer
        totalPages:
          type: integer
