@snagtag/adapter-rest
v0.2.1
Published
Generic REST API backend for SnagTag. Works with any server that implements the endpoint convention.
Readme
@snagtag/adapter-rest
Generic REST API backend for SnagTag. Works with any server that implements the endpoint convention.
Install
npm install @snagtag/adapter-rest @snagtag/coreUsage
import { createRestAdapter } from '@snagtag/adapter-rest'
const adapter = createRestAdapter({
baseUrl: 'https://api.example.com/snagtag',
headers: { Authorization: 'Bearer ...' }, // optional
tenantId: 'optional', // sent as X-Tenant-Id header
userId: 'optional', // sent as X-User-Id header
})Endpoint convention
| Method | Path | Purpose | |--------|------|---------| | GET | /reports | List reports (query params for filters) | | POST | /reports | Create report | | PATCH | /reports/:id | Update report | | DELETE | /reports/:id | Remove report | | GET | /reports/count-unresolved | Count unresolved | | GET | /reports/:id/similar | Find similar reports | | POST | /reports/mark-fixed | Mark fixed (body: ids, commitRef, notes) | | POST | /reports/reopen | Reopen (body: ids) | | POST | /screenshots | Upload (multipart) | | GET | /screenshots/:path | Get URL | | DELETE | /screenshots/:path | Delete | | GET | /groups | List groups | | POST | /groups | Create group | | POST | /groups/:id/assign | Assign reports | | GET | /sessions/active | Get active session | | POST | /sessions | Start session | | POST | /sessions/:id/end | End session |
Features
- Uses native
fetch()- zero dependencies - Configurable headers for auth
- Tenant/user scoping via headers
- Works with any backend that follows the convention
Note: Realtime is not supported (no onReportChange). Use polling or server-sent events in your backend.
License
MIT
