From f2643436b09e060a53951c9154039f456df777e2 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Mon, 3 Nov 2025 21:54:31 +0100 Subject: [PATCH] refactor: snapshots flat response --- apps/client/app/api-client/types.gen.ts | 16 +++++++--------- apps/client/app/lib/types.ts | 10 +++++++++- .../repositories/repositories.controller.ts | 4 +--- .../src/modules/repositories/repositories.dto.ts | 4 +--- openapi-ts.config.ts | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/apps/client/app/api-client/types.gen.ts b/apps/client/app/api-client/types.gen.ts index 034c25e..0ee4cab 100644 --- a/apps/client/app/api-client/types.gen.ts +++ b/apps/client/app/api-client/types.gen.ts @@ -791,15 +791,13 @@ export type ListSnapshotsResponses = { /** * List of snapshots */ - 200: { - snapshots: Array<{ - duration: number; - paths: Array; - short_id: string; - size: number; - time: number; - }>; - }; + 200: Array<{ + duration: number; + paths: Array; + short_id: string; + size: number; + time: number; + }>; }; export type ListSnapshotsResponse = ListSnapshotsResponses[keyof ListSnapshotsResponses]; diff --git a/apps/client/app/lib/types.ts b/apps/client/app/lib/types.ts index fb8d29a..1e304fc 100644 --- a/apps/client/app/lib/types.ts +++ b/apps/client/app/lib/types.ts @@ -1,4 +1,10 @@ -import type { GetBackupScheduleResponse, GetMeResponse, GetRepositoryResponse, GetVolumeResponse } from "~/api-client"; +import type { + GetBackupScheduleResponse, + GetMeResponse, + GetRepositoryResponse, + GetVolumeResponse, + ListSnapshotsResponse, +} from "~/api-client"; export type Volume = GetVolumeResponse["volume"]; export type StatFs = GetVolumeResponse["statfs"]; @@ -9,3 +15,5 @@ export type User = GetMeResponse["user"]; export type Repository = GetRepositoryResponse; export type BackupSchedule = GetBackupScheduleResponse; + +export type Snapshot = ListSnapshotsResponse[number]; diff --git a/apps/server/src/modules/repositories/repositories.controller.ts b/apps/server/src/modules/repositories/repositories.controller.ts index 7685caa..7323c77 100644 --- a/apps/server/src/modules/repositories/repositories.controller.ts +++ b/apps/server/src/modules/repositories/repositories.controller.ts @@ -69,9 +69,7 @@ export const repositoriesController = new Hono() }; }); - const response = { snapshots }; - - return c.json(response, 200); + return c.json(snapshots, 200); }) .get( "/:name/snapshots/:snapshotId/files", diff --git a/apps/server/src/modules/repositories/repositories.dto.ts b/apps/server/src/modules/repositories/repositories.dto.ts index 4e47160..fee5415 100644 --- a/apps/server/src/modules/repositories/repositories.dto.ts +++ b/apps/server/src/modules/repositories/repositories.dto.ts @@ -139,9 +139,7 @@ export const snapshotSchema = type({ duration: "number", }); -const listSnapshotsResponse = type({ - snapshots: snapshotSchema.array(), -}); +const listSnapshotsResponse = snapshotSchema.array(); export type ListSnapshotsDto = typeof listSnapshotsResponse.infer; diff --git a/openapi-ts.config.ts b/openapi-ts.config.ts index d0c26b1..5331d2c 100644 --- a/openapi-ts.config.ts +++ b/openapi-ts.config.ts @@ -1,7 +1,7 @@ import { defaultPlugins, defineConfig } from "@hey-api/openapi-ts"; export default defineConfig({ - input: "http://localhost:4096/api/v1/openapi.json", + input: "http://192.168.2.42:4096/api/v1/openapi.json", output: { path: "./apps/client/app/api-client", format: "biome",