Skip to content

apialerts/hapi-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hapi API

Hey look, an API written in GO on Google Cloud Run with a Postgres Database.

Environment Variables

Local Development

Use the Google Cloud SQL Auth Proxy

DB_USER=hapi
DB_PASSWORD=xxxx

Production Cloud Run

Use the Google Cloud SQL Connection String via UNIX sockets

CLOUD_SQL_INSTANCE=xxx
DB_USER=hapi
DB_PASSWORD=xxxx

Local Deploy

Use gcloud auth to authenticate with Google Cloud

gcloud run deploy api \
    --source . \
    --project hapi-9cd84 \
    --region us-central1 \
    --allow-unauthenticated

Public API

// Todo - secure export request

Export

POST http://localhost:8080/export

Request body:

{
  "endpoints": [
    {
      "id": 1,
      "name": "API Alerts",
      "url": "https://api.apialerts.com/health/cron",
      "method": "GET",
      "isActive": true,
      "slowThresholdMs": 500,
      "createdAt": 0
    },
    {
      "id": 2,
      "name": "Stripe",
      "url": "https://api.stripe.com/healthcheck",
      "method": "GET",
      "isActive": true,
      "slowThresholdMs": 200,
      "createdAt": 0
    }
  ]
}

Response Body:

{
    "code": "5OMRDTSE",
    "expiresAt": "2025-12-29T12:42:34.058193313Z"
}

Import

GET http://localhost:8080/import/5OMRDTSE

Response:

{
  "endpoints": [
    {
      "id": 1,
      "name": "API Alerts",
      "url": "https://api.apialerts.com/health/cron",
      "method": "GET",
      "isActive": true,
      "slowThresholdMs": 500,
      "createdAt": 0
    },
    {
      "id": 2,
      "name": "Stripe",
      "url": "https://api.stripe.com/healthcheck",
      "method": "GET",
      "isActive": true,
      "slowThresholdMs": 200,
      "createdAt": 0
    }
  ]
}

About

golang import/export backend for https://hapi.apialerts.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors