Skip to content

Commit f244283

Browse files
committed
feat: align examples with production contract
1 parent 876bb1b commit f244283

32 files changed

Lines changed: 1071 additions & 53 deletions

‎.github/dependabot.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 5
8+
9+
- package-ecosystem: github-actions
10+
directory: /
11+
schedule:
12+
interval: weekly
13+
open-pull-requests-limit: 5

‎.github/pull_request_template.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## What changed
2+
3+
Describe the developer-facing behavior this pull request changes.
4+
5+
## Contract impact
6+
7+
- [ ] No public API contract change
8+
- [ ] OpenAPI was changed in the private service repository and synchronized
9+
- [ ] Fixtures and examples were updated to match the contract
10+
11+
## Verification
12+
13+
- [ ] `npm run verify`
14+
- [ ] `npm run check:openapi-sync` when the service repository is available
15+
- [ ] `npm run smoke:live` for changes that affect public HTTP behavior
16+
- [ ] No API keys, webhook secrets, private media URLs, or customer data added

‎.github/workflows/live-smoke.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Live read-only smoke
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "17 3 * * 1"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
smoke:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
env:
16+
BEATAPI_API_KEY: ${{ secrets.BEATAPI_API_KEY }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: "22.12"
24+
cache: npm
25+
26+
- run: npm ci
27+
- run: npm run smoke:live

‎.github/workflows/verify.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ jobs:
1111
verify:
1212
runs-on: ubuntu-latest
1313
timeout-minutes: 10
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
node-version: ["20.19", "22.12"]
1418

1519
steps:
1620
- uses: actions/checkout@v4
1721

1822
- uses: actions/setup-node@v4
1923
with:
20-
node-version: 20
24+
node-version: ${{ matrix.node-version }}
2125
cache: npm
2226

2327
- uses: actions/setup-python@v5

‎CODE_OF_CONDUCT.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Code of Conduct
2+
3+
## Our standard
4+
5+
BeatAPI welcomes developers of every background and experience level. Be
6+
respectful, assume good intent, give actionable technical feedback, and keep
7+
discussions focused on improving developer integrations.
8+
9+
Unacceptable behavior includes harassment, discrimination, threats, publishing
10+
private information, sharing credentials or customer data, and repeatedly
11+
disrupting project discussions.
12+
13+
## Scope
14+
15+
This standard applies to repository issues, pull requests, discussions, and
16+
other spaces where someone is representing the BeatAPI project.
17+
18+
## Reporting
19+
20+
Report conduct concerns privately to support@beatapi.io. Do not use a public
21+
issue when a report contains personal information, credentials, security
22+
details, or customer data.
23+
24+
Project maintainers may edit or remove contributions and may temporarily or
25+
permanently restrict participation when behavior is unsafe or disruptive.

‎README.md‎

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Official runnable examples for the BeatAPI async AI video API.
44

5+
[![Verify examples](https://github.com/erickkkyt/beatapi-examples/actions/workflows/verify.yml/badge.svg)](https://github.com/erickkkyt/beatapi-examples/actions/workflows/verify.yml)
6+
57
[Website](https://beatapi.io/) ·
68
[API documentation](https://docs.beatapi.io/) ·
79
[Music Video Playground](https://beatapi.io/music-video-api) ·
@@ -17,6 +19,17 @@ The primary launch route is `POST /v1/music-video/tasks`.
1719
Create task -> queued/processing -> succeeded/failed -> hosted output
1820
```
1921

22+
```mermaid
23+
flowchart LR
24+
A["Create task"] --> B["queued / processing"]
25+
B --> C{"Final state?"}
26+
C -->|No| D["Wait 5-10 seconds"]
27+
D --> E["GET /v1/tasks/{task_id}"]
28+
E --> C
29+
C -->|succeeded| F["Read output.media"]
30+
C -->|failed| G["Inspect error_code and usage"]
31+
```
32+
2033
> This repository contains examples and a small reference client. It is not a
2134
> versioned SDK and it does not contain the BeatAPI service implementation.
2235
@@ -41,7 +54,8 @@ curl https://api.beatapi.io/v1/music-video/tasks \
4154
"prompt": "Neon rooftop performance with cinematic light trails.",
4255
"language": "en",
4356
"aspect_ratio": "9:16",
44-
"resolution": "720p"
57+
"resolution": "720p",
58+
"compose_mode": "auto"
4559
}'
4660
```
4761

@@ -78,7 +92,8 @@ are available in `data.output.media`.
7892

7993
### Node.js
8094

81-
Requires Node.js 20 or newer. No install step is required.
95+
The dependency-free examples require Node.js 20 or newer. Repository
96+
verification requires Node.js 20.19+ or 22.12+.
8297

8398
```bash
8499
node examples/node/music-video.mjs
@@ -157,6 +172,7 @@ credit, or concurrency errors.
157172
Webhook requests include:
158173

159174
```text
175+
X-BeatAPI-Event
160176
X-BeatAPI-Signature
161177
X-BeatAPI-Timestamp
162178
```
@@ -165,14 +181,28 @@ Verify the signature against the exact raw request body before parsing JSON,
165181
and reject timestamps older than five minutes. The Node.js receiver example
166182
implements HMAC-SHA256 verification with a constant-time comparison.
167183

184+
The signed JSON body uses `event`, not `type`:
185+
186+
```json
187+
{
188+
"id": "evt_example_123",
189+
"event": "task.succeeded",
190+
"created_at": 1784188934,
191+
"data": {
192+
"id": "task_8K2qA",
193+
"status": "succeeded"
194+
}
195+
}
196+
```
197+
168198
```bash
169199
export BEATAPI_WEBHOOK_SECRET="whsec_your_secret"
170200
node examples/node/webhook-server.mjs
171201
```
172202

173203
## Integration guides
174204

175-
- [n8n](integrations/n8n/README.md)
205+
- [n8n guide and importable bounded-polling workflow](integrations/n8n/README.md)
176206
- [Postman](integrations/postman/README.md)
177207
- [Sanitized response fixtures](fixtures/)
178208
- [Production API reference](https://docs.beatapi.io/)
@@ -202,6 +232,24 @@ npm run test:python
202232
npm run verify
203233
```
204234

235+
The public OpenAPI file is synchronized byte-for-byte from the private service
236+
repository:
237+
238+
```bash
239+
npm run sync:openapi
240+
npm run check:openapi-sync
241+
```
242+
243+
Run a read-only production smoke test with:
244+
245+
```bash
246+
npm run smoke:live
247+
```
248+
249+
Without `BEATAPI_API_KEY`, it checks anonymous workflow discovery. When the
250+
environment variable is present, it additionally verifies authenticated
251+
`GET /v1/usage`. The smoke test never creates tasks or consumes credits.
252+
205253
## License
206254

207255
Original example code in this repository is available under the

‎SECURITY.md‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
Do not open a public issue for vulnerabilities, exposed API keys, authentication
66
problems, webhook bypasses, credit issues, or customer data.
77

8-
Report security concerns privately through the contact method listed on
9-
[beatapi.io](https://beatapi.io/). Include the affected endpoint, impact,
10-
reproduction steps, and relevant request IDs. Remove API keys, webhook secrets,
11-
personal data, and private media URLs from the report.
8+
Report security concerns privately by emailing support@beatapi.io. Include the
9+
affected endpoint, impact, reproduction steps, and relevant request IDs. Remove
10+
API keys, webhook secrets, personal data, and private media URLs from the
11+
report.
12+
13+
GitHub private vulnerability reporting can be enabled when this repository
14+
becomes public. Until then, do not use a public issue for a security report.
1215

1316
## API key exposure
1417

‎examples/curl/music-video.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ curl --fail-with-body --silent --show-error \
1414
"prompt": "Neon rooftop performance with cinematic light trails.",
1515
"language": "en",
1616
"aspect_ratio": "9:16",
17-
"resolution": "720p"
17+
"resolution": "720p",
18+
"compose_mode": "auto"
1819
}'

‎examples/node/lib/webhook.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { createHmac, timingSafeEqual } from "node:crypto";
22

3+
export function describeBeatAPIWebhookEvent(payload) {
4+
const event = payload?.event || "unknown event";
5+
const taskId = payload?.data?.id || "unknown task";
6+
return `${event} for ${taskId}`;
7+
}
8+
39
export function verifyBeatAPIWebhook({
410
rawBody,
511
secret,

‎examples/node/music-video.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ try {
1111
language: "en",
1212
aspect_ratio: "9:16",
1313
resolution: "720p",
14+
compose_mode: "auto",
1415
});
1516

1617
console.log(`Created ${created.id}`);

0 commit comments

Comments
 (0)