Project

bard-api

0.0
The project is in a healthy, maintained state
Rack app that mounts in Rails projects to expose management endpoints for BARD Tracker
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

Runtime

>= 0
>= 0
>= 0
 Project Readme

Bard::Api

REST API for BARD-managed Rails projects. This gem provides a lightweight Rack application that mounts in Rails projects to expose management endpoints for BARD Tracker.

Overview

The bard-api gem enables BARD Tracker to manage Rails applications through a REST API. It provides:

  • Database backups: Trigger and monitor database backups using Backhoe
  • Health monitoring: Check application status

Usage

Mounting in Rails

Add to your config/routes.rb:

mount Bard::Api::App.new => "/bard-api"

This makes the API available at /bard-api/* endpoints.

Endpoints

GET /bard-api/health

Health check endpoint (no authentication required).

Response:

{
  "status": "ok"
}

POST /bard-api/backups

Trigger a backup (requires JWT authentication).

Headers:

Authorization: Bearer <jwt-token>

Request:

{
  "urls": [
    "https://s3.amazonaws.com/presigned-url..."
  ]
}

Response (200 OK):

{
  "timestamp": "2025-12-06T10:30:00Z",
  "size": 123456789,
  "destinations": [
    {
      "name": "bard",
      "type": "bard",
      "status": "success"
    }
  ]
}

GET /bard-api/backups/latest

Get status of most recent backup (requires JWT authentication).

Headers:

Authorization: Bearer <jwt-token>

Response (200 OK):

{
  "timestamp": "2025-12-06T10:30:00Z",
  "destinations": [
    {
      "name": "primary",
      "type": "s3",
      "path": "bard-backup/my-app",
      "region": "us-west-2"
    }
  ]
}

Response (404 Not Found):

{
  "error": "No backups found"
}

Authentication

The API uses JWT with asymmetric RSA keys for authentication. The public key is embedded in the gem, and only BARD Tracker with the private key can create valid tokens.

Tokens expire after 5 minutes and must include:

  • urls: Array of presigned S3 URLs for backup destinations
  • exp: Expiration timestamp
  • iat: Issued at timestamp

License

The gem is available as open source under the terms of the MIT License.