bard-api 0.3.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4aaf92f7575ac16f3e63cabf871e1a7d21732ef2a28bebddc84d1044e06624d2
4
- data.tar.gz: 81a07fcecb266586c89f954c7e14cbcc70ae9de1cf7a5422801a687c87b2c0f8
3
+ metadata.gz: 60efdcaa06460e992d61dcf738ee45a2f45c1c681c7a7ad79fa16691f73af1f6
4
+ data.tar.gz: a2dceba794d6160e4f7d19a97c2e632e6d4a3bf92ae8667e6c3578d4bafa16cd
5
5
  SHA512:
6
- metadata.gz: d63a639cb55df2b3625b3aa8a802c073f97ac8e23629d131e2e46a44b2586347446155295687247f748cd9ac717170875b75824be481a34bcae28cfd846d425d
7
- data.tar.gz: 38ee9ca23f77e8c806175f4f03a2ff4528d43d26efbab3f811fbed19d0452c9f3a4cdeda307633e3fbeec948825e7d048c663b12424ab8bca136e0f7cbfa9e23
6
+ metadata.gz: 994347c9042e652d6099d584ce4d599d19338bb295ca7fabb73087e6f29b042bc7853cbe51b0e8749cd85378d0edce97175096b6a37d541670b235f4e8fb8ced
7
+ data.tar.gz: 46c4672f58864f00c677369e7ac5cfbbed64285aef40096a2538b4ff5af305d34160a81ce7c6e92a0996bef7f6fc7f891f56eba3addb563850372c747b92fc78
data/README.md CHANGED
@@ -98,6 +98,36 @@ Authorization: Bearer <jwt-token>
98
98
  }
99
99
  ```
100
100
 
101
+ #### GET /bard-api/config
102
+
103
+ Read the project's live backup and uptime configuration (requires JWT authentication). Used by axis to discover what each project actually has deployed.
104
+
105
+ **Headers:**
106
+ ```
107
+ Authorization: Bearer <jwt-token>
108
+ ```
109
+
110
+ **Response (200 OK):**
111
+ ```json
112
+ {
113
+ "project_name": "my-app",
114
+ "backup": {
115
+ "enabled": true,
116
+ "bard_managed": true,
117
+ "self_managed": false,
118
+ "encryption_enabled": true,
119
+ "destinations": [
120
+ { "name": "primary", "type": "s3" }
121
+ ]
122
+ },
123
+ "servers": {
124
+ "production": { "pings": ["https://my-app.example.com/health"] }
125
+ }
126
+ }
127
+ ```
128
+
129
+ Destination entries expose only `name` and `type`; bucket paths, regions, and credentials are never serialized. `servers` is `{}` when no production server is configured.
130
+
101
131
  ### Authentication
102
132
 
103
133
  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.
data/lib/bard/api/app.rb CHANGED
@@ -20,6 +20,8 @@ module Bard
20
20
  create_backup(request)
21
21
  when ["GET", "/backups/latest"]
22
22
  latest_backup(request)
23
+ when ["GET", "/config"]
24
+ config(request)
23
25
  else
24
26
  not_found
25
27
  end
@@ -35,11 +37,15 @@ module Bard
35
37
 
36
38
  def create_backup(request)
37
39
  with_auth(request) do |payload|
40
+ s3 = payload["s3"].transform_keys(&:to_sym)
41
+ project_name = Bard::Config.current.project_name
42
+
38
43
  backup = Bard::Backup.create!(
39
- name: "bard",
40
- type: :upload,
41
- urls: payload["urls"]
44
+ type: :s3,
45
+ path: "bard-backup/#{project_name}",
46
+ **s3,
42
47
  )
48
+
43
49
  json_response(200, backup.as_json)
44
50
  end
45
51
  end
@@ -53,6 +59,28 @@ module Bard
53
59
  json_response(404, { error: e.message })
54
60
  end
55
61
 
62
+ def config(request)
63
+ with_auth(request) do
64
+ json_response(200, serialize_config(Bard::Config.current))
65
+ end
66
+ end
67
+
68
+ def serialize_config(bard_config)
69
+ backup = bard_config.backup
70
+ production = bard_config.targets[:production]
71
+ {
72
+ project_name: bard_config.project_name,
73
+ backup: {
74
+ enabled: backup.enabled?,
75
+ bard_managed: backup.bard?,
76
+ self_managed: backup.self_managed?,
77
+ encryption_enabled: !!bard_config.encrypt,
78
+ destinations: backup.destinations.map { |d| { name: d[:name], type: d[:type] } },
79
+ },
80
+ servers: production ? { production: { pings: production.ping } } : {},
81
+ }
82
+ end
83
+
56
84
  def with_auth(request)
57
85
  payload = Auth.verify!(request.env["HTTP_AUTHORIZATION"])
58
86
  yield payload
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bard
4
4
  module Api
5
- VERSION = "0.3.2"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-12-15 00:00:00.000000000 Z
10
+ date: 2026-05-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: jwt
@@ -57,28 +57,28 @@ dependencies:
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: '2.0'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '0'
67
+ version: '2.0'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: bard-backup
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '0'
74
+ version: '0.10'
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '0'
81
+ version: '0.10'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rack-test
84
84
  requirement: !ruby/object:Gem::Requirement