|
|
hai 2 semanas | |
|---|---|---|
| .. | ||
| src | hai 2 semanas | |
| test | hai 1 mes | |
| .prettierrc | hai 1 mes | |
| README.md | hai 1 mes | |
| dev-restart.sh | hai 3 semanas | |
| eslint.config.mjs | hai 1 mes | |
| nest-cli.json | hai 1 mes | |
| nodemon-prod.json | hai 3 semanas | |
| nodemon.json | hai 3 semanas | |
| package.json | hai 3 semanas | |
| tsconfig.build.json | hai 1 mes | |
| tsconfig.json | hai 1 mes | |
A NestJS-based REST API service for the Watch Finished system. Provides endpoints for file management, task processing, configuration, and real-time WebSocket communication.
graph TB
subgraph "Controllers"
FC[FilesController<br/>/files/*]
TC[TasksController<br/>/tasks/*]
CC[ConfigController<br/>/config/*]
WC[WatcherController<br/>/watcher/*]
MC[MaintenanceController<br/>/maintenance/*]
end
subgraph "Services"
FS[FilesService<br/>CRUD operations]
TS[TasksService<br/>Queue management]
CS[ConfigService<br/>Settings]
WS[WatcherService<br/>File monitoring]
HS[HandbrakeService<br/>Video processing]
DBS[DbService<br/>SQLite access]
MS[MaintenanceService<br/>Cleanup]
end
subgraph "Gateway"
EG[EventsGateway<br/>WebSocket events]
end
subgraph "Database"
DB[(SQLite)]
end
FC --> FS
TC --> TS
CC --> CS
WC --> WS
MC --> MS
FS --> DBS
TS --> DBS
CS --> DBS
WS --> DBS
MS --> DBS
WS --> TS
TS --> HS
HS --> EG
DBS --> DB
EG --> EG
style FC fill:#e3f2fd
style EG fill:#f3e5f5
style DB fill:#e8f5e8
GET /files - List all datasetsGET /files/:dataset/:file - Get specific filePOST /files/:dataset/:file - Create/update fileDELETE /files/:dataset/:file - Delete filePOST /files/:dataset/:file/requeue - Requeue for processingGET /tasks - List all tasksGET /tasks/:id - Get task detailsDELETE /tasks/:id - Delete taskPOST /tasks/queue/settings - Update queue settingsGET /config/settings - Get all settingsPOST /config/settings - Update settingsGET /config/settings/:key - Get specific settingGET /watcher/status - Get watcher statusPOST /watcher/start - Start file watcherPOST /watcher/stop - Stop file watcherPOST /maintenance/cleanup - Clean up processed filesPOST /maintenance/purge - Purge old filesPOST /maintenance/prune - Remove empty directoriesGET /handbrake/presets - Get available presetsPOST /handbrake/process - Process video with HandBrakeThe service emits real-time events via Socket.IO:
taskUpdate - Task progress and status changesfileUpdate - File additions, updates, deletionswatcherUpdate - Watcher start/stop statusmaintenanceUpdate - Maintenance operation resultsUses SQLite database stored at ../../../data/database.db relative to the service directory. Contains tables for:
files - Processed video filestasks - Processing queuesettings - Configuration values# Install dependencies
pnpm install
# Run in development mode with hot reload
pnpm run start:dev
# Build for production
pnpm run build
pnpm run start:prod
PORT - Server port (default: 3001)import { io } from 'socket.io-client';
const socket = io('http://localhost:3000');
// Listen for events
socket.on('fileUpdate', (data) => {
console.log('File update:', data);
});
socket.on('watcherUpdate', (data) => {
console.log('Watcher update:', data);
});
Clients can join/leave rooms for targeted messaging:
// Join a room
socket.emit('join', { room: 'dashboard' });
// Leave a room
socket.emit('leave', { room: 'dashboard' });
Nest framework TypeScript starter repository.
$ pnpm install
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
# unit tests
$ pnpm run test
# e2e tests
$ pnpm run test:e2e
# test coverage
$ pnpm run test:cov
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ pnpm install -g @nestjs/mau
$ mau deploy
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
Check out a few resources that may come in handy when working with NestJS:
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Nest is MIT licensed.
A modern NestJS API for managing files, settings, watcher, and tasks, all backed by a unified SQLite database.
http://localhost:3000GET /files — List available datasetsPOST /files/:dataset/:file — Create file recordPOST /files/:dataset/:file/update — Update file recordGET /files/:dataset/:file — Get file recordDELETE /files/:dataset/:file — Delete file recordGET /files/:dataset/status/:status — List files by statusGET /files/:dataset/deleted-older-than/:isoDate — List deleted files older than datePOST /files/expire — Delete expired filesPOST /files/migrate — Migrate legacy JSON to SQLite
GET /config/settings — Get all settings
GET /config/settings?key=... — Get setting by key
POST /config/settings — Update setting
DELETE /config/settings/:key — Delete setting
GET /watcher/status — Get watcher status
POST /watcher/start — Start watcher
POST /watcher/stop — Stop watcher
GET /tasks — List tasks
POST /tasks — Create task
DELETE /tasks/:id — Delete task
GET / — API root
GET /ready — Readiness probe
GET /health — Health check
flowchart TD
A[Client (Web/CLI)] -->|REST| B(API Service)
B -->|SQL| C[(SQLite database)]
B --> D[Watcher]
B --> E[HandBrake]
B --> F[Maintenance]
POST /files/movies/myfile.mp4
{
"output": "output.mp4",
"status": "success",
"date": "2025-12-30T12:00:00Z"
}
See ../docs/README.md for full project documentation.