bard-api 0.3.1 → 0.4.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: 70f38ef8f674aefa2cdcfba3586e87d644c10026943625bd82cb2be180f0035b
4
- data.tar.gz: 1fd66c7e938efe753797d99e594c03f802948c004adafe0991b2b5577a00fb73
3
+ metadata.gz: 5356ba0a76baa3fea6495b9a18b831c1e584f68b558fb9e9807b42d47f4d592b
4
+ data.tar.gz: 240980678c50c10a37ee10e4a0de04955314be35361cc7ddb93adb8524eaf071
5
5
  SHA512:
6
- metadata.gz: 6ce89073234248cf2a6ec1cc628bb97fcbf8f8d96e8be9d46dd117f54b1f18277e4c81cd9ec3ba2fb7fbd6fc1ef53bed84532f603db84ffda376cbd87b08f28e
7
- data.tar.gz: 1119c0bc33153aeb74d53ec585c59b7bade8c410eda343962e9c2d5cf04bb017e8d2cb7e441c31c89c1dd4b687dcccc0ed1121e5fc7de2d8fbe158ce7ac34e8e
6
+ metadata.gz: 6218ddf87a7373a67469ac4e25dff989f65b2d3704d6ed23b4379740e7d4a231962cca7f3fd44f53c995096cd3a102d9d7248d0e655f7e5ada53c788e140efdd
7
+ data.tar.gz: 057fabfeb1a55b64dfbae9d16a3b917ff321d75faebb823dfc9618ab334d6ab2849cd81028452d159a5df558906603056c0abe630b706e272e534d00aa66c634
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,11 @@ module Bard
35
37
 
36
38
  def create_backup(request)
37
39
  with_auth(request) do |payload|
38
- backup = Bard::Backup.create!({
40
+ backup = Bard::Backup.create!(
39
41
  name: "bard",
40
42
  type: :upload,
41
43
  urls: payload["urls"]
42
- })
44
+ )
43
45
  json_response(200, backup.as_json)
44
46
  end
45
47
  end
@@ -53,6 +55,28 @@ module Bard
53
55
  json_response(404, { error: e.message })
54
56
  end
55
57
 
58
+ def config(request)
59
+ with_auth(request) do
60
+ json_response(200, serialize_config(Bard::Config.current))
61
+ end
62
+ end
63
+
64
+ def serialize_config(bard_config)
65
+ backup = bard_config.backup
66
+ production = bard_config.servers[:production]
67
+ {
68
+ project_name: bard_config.project_name,
69
+ backup: {
70
+ enabled: backup.enabled?,
71
+ bard_managed: backup.bard?,
72
+ self_managed: backup.self_managed?,
73
+ encryption_enabled: bard_config.respond_to?(:encrypt) && !!bard_config.encrypt,
74
+ destinations: backup.destinations.map { |d| { name: d[:name], type: d[:type] } },
75
+ },
76
+ servers: production ? { production: { pings: Array(production.ping) } } : {},
77
+ }
78
+ end
79
+
56
80
  def with_auth(request)
57
81
  payload = Auth.verify!(request.env["HTTP_AUTHORIZATION"])
58
82
  yield payload
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bard
4
4
  module Api
5
- VERSION = "0.3.1"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-12-11 00:00:00.000000000 Z
10
+ date: 2026-05-15 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: jwt
@@ -118,7 +117,6 @@ licenses:
118
117
  metadata:
119
118
  homepage_uri: https://github.com/botandrose/bard-api
120
119
  source_code_uri: https://github.com/botandrose/bard-api
121
- post_install_message:
122
120
  rdoc_options: []
123
121
  require_paths:
124
122
  - lib
@@ -133,8 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
131
  - !ruby/object:Gem::Version
134
132
  version: '0'
135
133
  requirements: []
136
- rubygems_version: 3.5.11
137
- signing_key:
134
+ rubygems_version: 3.6.2
138
135
  specification_version: 4
139
136
  summary: REST API for BARD-managed Rails projects
140
137
  test_files: []