@casperjuel/datocms-backup-api
v1.0.10
Published
Backend API for DatoCMS automatic environment backups
Maintainers
Readme
@casperjuel/datocms-backup-api
Backend API utilities for DatoCMS automatic environment backups. Used by the DatoCMS Backup API Template.
Installation
npm install @casperjuel/datocms-backup-apiQuick Start
Deploy your own backup API using our template:
Usage
This package exports utilities for building DatoCMS backup APIs:
import {
// Storage
getConfig,
setConfig,
addRun,
getRunHistory,
// Auth
verifyCronSecret,
getApiToken,
// DatoCMS operations
createBackup,
cleanupOldBackups,
// Scheduling
getScheduledBackups,
generateBackupEnvironmentId,
enforceRetention,
// Validation
validateProjectId,
validateApiTokenFormat,
// Types
type BackupConfig,
type BackupRun,
} from '@casperjuel/datocms-backup-api';Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| KV_REST_API_URL | Yes | Vercel KV REST API URL |
| KV_REST_API_TOKEN | Yes | Vercel KV REST API token |
| CRON_SECRET | Yes | Secret for cron endpoint authentication |
| API_SECRET | No | Secret for API endpoint authentication |
| ENCRYPTION_KEY | No | 64 hex chars for encrypting stored tokens |
API Endpoints
When used with the template, provides these endpoints:
| Endpoint | Method | Description |
|----------|--------|-------------|
| /api/health | GET | Health check |
| /api/config | GET, PUT, DELETE | Configuration management |
| /api/backup/trigger | POST | Trigger manual backup |
| /api/backup/history | GET | Get backup history |
| /api/cron/backup | GET | Cron endpoint (Vercel cron) |
Related
- DatoCMS Backup API Template - Deploy template
- @casperjuel/datocms-backup-shared - Shared types
License
MIT
