Repository navigation
feat(api): add a REST API with API keys and OpenAPI docs - #693
Fredobumma wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 12 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 2 unresolved issues already reported by Cubic.
View guided diff | Re-trigger cubic
|
What do you think about having api keys under account tab instead? |
So I'll move the keys into the account page, under the email and password form, and remove the separate page and the header link. |
Adds a REST API at
/api/v1, so scripts and tools such as n8n can convert files without the web interface. Closes #363.What it adds
POST /api/v1/converttakes a file and a target format and responds with the converted file.POST /api/v1/jobsstarts a job and returns202with aLocationheader.GET /api/v1/jobs/{id}reports each file's status and links its results, which download one by one (/files/{name}) or together as a tar (/archive).GET /api/v1/jobslists jobs, newest first, andDELETE /api/v1/jobs/{id}removes a job with its files.GET /api/v1/targets?from=docxlists what a format can become, and which converters can do it.GET /api/v1/converterslists every converter with what it reads and writes./account/api-keyscreates and revokes keys. It's linked from the header and the account page. A key is shown once. Only its SHA-256 hash is stored, with a short prefix so people can tell keys apart, and the time it was last used. Requests send it asAuthorization: Bearer <key>orX-API-Key: <key>./api/v1/openapi.json, and Swagger UI at/api/v1/docs. Only the API is documented, not the web pages. The README gets an "API" section.Errors are JSON:
{ "error": "<code>", "message": "<explanation>" }. For example,422 unsupported_conversionnames the converters that can do the conversion when the requested one can't.Testing
tests/api/api.test.ts, using the existingtests/preload.tssetup. They cover keys (including that only a hash is stored and revoking locks a key out), both ways of converting, jobs, downloads and archives, deletion, users not seeing each other's jobs, error responses, and the OpenAPI document.bun run lintandbun run testpass (484 tests).Screenshots