Skip to content

Alter-Igor/sayhello-api

Repository files navigation

SayHello API Testing Service

A lightweight Node.js API testing server for exercising HTTP requests and inspecting traffic. Perfect for integration testing, debugging API calls, and verifying authentication flows.

Features

  • ✅ All HTTP methods supported (GET, POST, PUT, DELETE, PATCH, etc.)
  • ✅ CORS enabled for frontend testing
  • ✅ Detailed request/response logging (5-minute retention for security)
  • ✅ Material Design 3 UI for landing page and monitoring dashboard
  • ✅ Real-time monitoring with auto-refresh
  • ✅ Swagger/OpenAPI documentation
  • ✅ Built-in metrics and performance insights
  • ✅ Authentication header capture
  • ✅ Comprehensive IP address detection (for whitelisting)

Local Development

Prerequisites

  • Node.js 18+
  • npm

Setup

# Install dependencies
npm install

# Create .env file (optional, for ngrok)
cp .env.example .env

# Start server
npm start

The server will start on http://localhost:3030

Response Format

All endpoints return:

{
  "message": "Hello {timestamp}",
  "type": "HTTP_METHOD",
  "youSentMe": "request_body_if_any",
  "requestDetails": {
    "timestamp": "2025-09-25T03:02:01.528Z",
    "method": "POST",
    "url": "/api/test?debug=true",
    "path": "/api/test",
    "query": { "debug": "true" },
    "headers": { ... },
    "authenticationHeaders": { "authorization": "Bearer token" },
    "body": { ... },
    "contentType": "application/json",
    "userAgent": "curl/8.7.1",
    "ip": "::1",
    ...
  },
  "server": {
    "name": "SayHello API Testing Server",
    "version": "1.0.0",
    "port": 3030,
    "timestamp": "2025-09-25T03:02:01.528Z"
  }
}

Available Endpoints

  • / - Landing page with integration instructions
  • /monitor.html - Real-time monitoring dashboard
  • /docs - Swagger API documentation
  • /health - Health check endpoint
  • /metrics - Performance metrics and request logs
  • /echo - Echo endpoint (returns request details)
  • /test - Simple test endpoint

Testing Examples

# GET request
curl http://localhost:3030/

# POST with JSON body and auth headers
curl -X POST http://localhost:3030/test \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer test-token-123" \
  -H "X-API-Key: my-secret-key" \
  -d '{"name": "Test User", "action": "testing"}'

# DELETE with query parameters
curl -X DELETE "http://localhost:3030/api/users/123?debug=true" \
  -H "Authorization: Basic dGVzdDpwYXNzd29yZA=="

# Health check
curl http://localhost:3030/health

Azure Deployment

This service automatically deploys to Azure Container Apps when you push to the main branch.

Azure Resources

  • Resource Group: rg-alterspective-utilities-prod
  • Container Registry: acralterspectiveutils.azurecr.io
  • Container App: ca-sayhello-prod
  • Environment: cae-alterspective-utilities-prod

First-Time Setup

1. Create Azure Service Principal for GitHub Actions

az ad sp create-for-rbac \
  --name "github-actions-sayhello" \
  --role contributor \
  --scopes /subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/rg-alterspective-utilities-prod \
  --sdk-auth

Copy the entire JSON output.

2. Configure GitHub Secrets

Go to your GitHub repository → Settings → Secrets and variables → Actions

Add the following secrets:

  • AZURE_CREDENTIALS: Paste the JSON output from step 1
  • NGROK_AUTHTOKEN: Your ngrok auth token (from .env file)
  • NGROK_DOMAIN: Your ngrok domain (e.g., sayhello.alterspective.io)

3. Push to GitHub

git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO.git
git push -u origin main

The GitHub Actions workflow will automatically:

  1. Build a Docker image
  2. Push to Azure Container Registry
  3. Deploy to Azure Container Apps
  4. Output the public URL

Manual Deployment

If you need to deploy manually:

# Build and push Docker image
az acr build \
  --registry acralterspectiveutils \
  --image sayhello:latest \
  --file Dockerfile .

# Deploy to Container App
az containerapp create \
  --name ca-sayhello-prod \
  --resource-group rg-alterspective-utilities-prod \
  --environment cae-alterspective-utilities-prod \
  --image acralterspectiveutils.azurecr.io/sayhello:latest \
  --target-port 3030 \
  --ingress external \
  --min-replicas 0 \
  --max-replicas 3 \
  --cpu 0.5 \
  --memory 1Gi

Using with ShareDo

See the integration instructions on the landing page at / for step-by-step guidance on configuring this service with ShareDo's Linked Services.

Security

  • Request logs containing sensitive data (headers, bodies, tokens) are automatically deleted after 5 minutes
  • Do not commit .env files to version control
  • Azure secrets are stored securely in GitHub Secrets and Azure Key Vault

Cost Optimization

Azure Container Apps scales to zero when not in use, so you only pay for:

  • Execution time when the service is actively handling requests
  • First 180,000 vCPU-seconds/month are free
  • First 360,000 GiB-seconds/month are free
  • First 2 million requests/month are free

For infrequent usage (once every 2 months), costs should be minimal or free.

Monitoring

Access the monitoring dashboard at /monitor.html to see:

  • Real-time request/response logs
  • Performance metrics
  • Memory usage
  • Request rates

License

Copyright © Alterspective

About

SayHello API Testing Service - A lightweight Node.js API testing server for debugging and integration testing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors