paired with bolt hackathon
Go to file
Isaac Johnson ed8cba13a7 Docker, Helm and Gitea Workflow 2025-06-18 07:05:24 -05:00
.bolt first 2025-06-15 09:47:15 -05:00
.gitea/workflows Docker, Helm and Gitea Workflow 2025-06-18 07:05:24 -05:00
helm/logingest Docker, Helm and Gitea Workflow 2025-06-18 07:05:24 -05:00
middleware first 2025-06-15 09:47:15 -05:00
services Docker, Helm and Gitea Workflow 2025-06-18 07:05:24 -05:00
supabase/migrations first 2025-06-15 09:47:15 -05:00
utils Docker, Helm and Gitea Workflow 2025-06-18 07:05:24 -05:00
.env.example first 2025-06-15 09:47:15 -05:00
.gitignore first 2025-06-15 09:47:15 -05:00
Dockerfile Docker, Helm and Gitea Workflow 2025-06-18 07:05:24 -05:00
README.md first 2025-06-15 09:47:15 -05:00
index.js first 2025-06-15 09:47:15 -05:00
package-lock.json first 2025-06-15 09:47:15 -05:00
package.json first 2025-06-15 09:47:15 -05:00
server.js Docker, Helm and Gitea Workflow 2025-06-18 07:05:24 -05:00

README.md

Log Microservice

A Node.js microservice that receives log data via POST requests with basic authentication and stores them in a PostgreSQL database via Supabase.

Features

  • HTTP API: RESTful endpoints for receiving log data
  • Basic Authentication: Secure endpoints with username/password authentication
  • PostgreSQL Storage: Stores logs in Supabase PostgreSQL database
  • Input Validation: Validates incoming data and provides meaningful error messages
  • Default Values: Automatically applies default values for optional fields
  • Health Check: Built-in health check endpoint

API Endpoints

POST /logs

Receives log data and stores it in the database.

Authentication: Basic Auth required

Request Body:

{
  "message": "This is a log message (required)",
  "project": "My Project (optional, defaults to 'Project 1')",
  "type": "Error (optional, defaults to 'Info')",
  "owner": "john.doe (optional, defaults to 'N/A')",
  "avatar_src": "/custom-avatar.png (optional, defaults to '/rectangle-15.png')",
  "status": "Active (optional, defaults to 'Pending')"
}

Response:

{
  "success": true,
  "message": "Log entry created successfully",
  "id": 1703123456
}

GET /health

Health check endpoint to verify service status.

Response:

{
  "status": "healthy",
  "timestamp": "2024-01-01T12:00:00.000Z"
}

Setup

  1. Set up Supabase: Click the "Connect to Supabase" button to configure your database
  2. Configure Environment: Copy .env.example to .env and update the values
  3. Run the Service: Use npm start to start the microservice

Database Schema

The service automatically creates a logs table with the following structure:

  • id (bigint) - Epoch time identifier
  • body (text) - First 200 characters of the message
  • project (text) - Project name
  • type (text) - Log type (Info, Error, Warning, etc.)
  • date (date) - Date of the log entry
  • avatar_src (text) - Avatar image source
  • owner (text) - Owner of the log entry
  • description (text) - Full log message
  • created_at (timestamptz) - Creation timestamp
  • status (text) - Status of the log entry

Authentication

The service uses HTTP Basic Authentication. Default credentials:

  • Username: admin
  • Password: password123

Update these in your .env file for production use.

Usage Example

# Using curl to send a log entry
curl -X POST http://localhost:3000/logs \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic YWRtaW46cGFzc3dvcmQxMjM=" \
  -d '{
    "message": "User login successful",
    "project": "Authentication Service",
    "type": "Info",
    "owner": "auth-service"
  }'

Error Handling

The service provides detailed error responses:

  • 400 Bad Request: Invalid input data
  • 401 Unauthorized: Missing or invalid authentication
  • 404 Not Found: Unknown endpoint
  • 500 Internal Server Error: Database or server errors