chore: initial commit — monorepo ReadaBook (API NestJS, web PWA, Docker)

This commit is contained in:
Git Agent
2026-08-23 09:56:53 +02:00
commit 8f1140127f
79 changed files with 6456 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import { Module } from "@nestjs/common";
import { DatabaseModule } from "../database/database.module.js";
import { JobsService } from "./jobs.service.js";
@Module({
imports: [DatabaseModule],
providers: [JobsService],
exports: [JobsService]
})
export class JobsModule {}

View File

@ -0,0 +1,46 @@
import { Injectable } from "@nestjs/common";
import { desc, eq } from "drizzle-orm";
import { DatabaseService } from "../database/database.service.js";
import { jobs } from "../database/schema.js";
@Injectable()
export class JobsService {
constructor(private readonly database: DatabaseService) {}
create(type: string, detail?: string) {
const now = this.database.now();
return this.database.db
.insert(jobs)
.values({ type, status: "queued", detail: detail ?? null, error: null, createdAt: now, updatedAt: now })
.returning()
.get();
}
markRunning(id: number, detail?: string): void {
this.database.db
.update(jobs)
.set({ status: "running", detail: detail ?? null, updatedAt: this.database.now() })
.where(eq(jobs.id, id))
.run();
}
markSucceeded(id: number, detail?: string): void {
this.database.db
.update(jobs)
.set({ status: "succeeded", detail: detail ?? null, error: null, updatedAt: this.database.now() })
.where(eq(jobs.id, id))
.run();
}
markFailed(id: number, error: unknown): void {
this.database.db
.update(jobs)
.set({ status: "failed", error: error instanceof Error ? error.message : String(error), updatedAt: this.database.now() })
.where(eq(jobs.id, id))
.run();
}
list(limit = 50) {
return this.database.db.select().from(jobs).orderBy(desc(jobs.createdAt)).limit(limit).all();
}
}