mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
fix: form reset and default values
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hono/arktype-validator": "^2.0.1",
|
||||
"@hono/standard-validator": "^0.1.5",
|
||||
"@ironmount/schemas": "workspace:*",
|
||||
"@scalar/hono-api-reference": "^0.9.13",
|
||||
"arktype": "^2.1.20",
|
||||
@@ -16,7 +17,7 @@
|
||||
"dotenv": "^17.2.1",
|
||||
"drizzle-orm": "^0.44.4",
|
||||
"hono": "^4.9.2",
|
||||
"hono-openapi": "^0.4.8",
|
||||
"hono-openapi": "^1.1.0",
|
||||
"http-errors-enhanced": "^3.0.2",
|
||||
"node-cron": "^4.2.1",
|
||||
"slugify": "^1.6.6",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Scalar } from "@scalar/hono-api-reference";
|
||||
import { Hono } from "hono";
|
||||
import { serveStatic } from "hono/bun";
|
||||
import { logger as honoLogger } from "hono/logger";
|
||||
import { openAPISpecs } from "hono-openapi";
|
||||
import { openAPIRouteHandler } from "hono-openapi";
|
||||
import { runDbMigrations } from "./db/db";
|
||||
import { driverController } from "./modules/driver/driver.controller";
|
||||
import { startup } from "./modules/lifecycle/startup";
|
||||
@@ -12,14 +12,14 @@ import { handleServiceError } from "./utils/errors";
|
||||
import { logger } from "./utils/logger";
|
||||
|
||||
export const generalDescriptor = (app: Hono) =>
|
||||
openAPISpecs(app, {
|
||||
openAPIRouteHandler(app, {
|
||||
documentation: {
|
||||
info: {
|
||||
title: "Ironmount API",
|
||||
version: "1.0.0",
|
||||
description: "API for managing volumes",
|
||||
},
|
||||
servers: [{ url: "http://localhost:3000", description: "Development Server" }],
|
||||
servers: [{ url: "http://localhost:4096", description: "Development Server" }],
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import { BACKEND_STATUS, type BackendConfig } from "@ironmount/schemas";
|
||||
import type { VolumeBackend } from "../backend";
|
||||
import { logger } from "../../../utils/logger";
|
||||
import { withTimeout } from "../../../utils/timeout";
|
||||
import { OPERATION_TIMEOUT } from "../../../core/constants";
|
||||
import { toMessage } from "../../../utils/errors";
|
||||
import { logger } from "../../../utils/logger";
|
||||
import { getMountForPath } from "../../../utils/mountinfo";
|
||||
import { withTimeout } from "../../../utils/timeout";
|
||||
import type { VolumeBackend } from "../backend";
|
||||
import { createTestFile, executeMount, executeUnmount } from "../utils/backend-utils";
|
||||
|
||||
const mount = async (config: BackendConfig, path: string) => {
|
||||
@@ -78,10 +78,9 @@ const unmount = async (path: string) => {
|
||||
|
||||
try {
|
||||
return await withTimeout(run(), OPERATION_TIMEOUT, "NFS unmount");
|
||||
} catch (err: any) {
|
||||
const msg = err.stderr?.toString().trim() || err.message;
|
||||
logger.error("Error unmounting NFS volume", { path, error: msg });
|
||||
return { status: BACKEND_STATUS.error, error: msg };
|
||||
} catch (err) {
|
||||
logger.error("Error unmounting NFS volume", { path, error: toMessage(err) });
|
||||
return { status: BACKEND_STATUS.error, error: toMessage(err) };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Hono } from "hono";
|
||||
import { validator } from "hono-openapi/arktype";
|
||||
import { validator } from "hono-openapi";
|
||||
import {
|
||||
createVolumeBody,
|
||||
createVolumeDto,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { volumeConfigSchema } from "@ironmount/schemas";
|
||||
import { volumeConfigSchemaNoUndefined } from "@ironmount/schemas";
|
||||
import { type } from "arktype";
|
||||
import { describeRoute } from "hono-openapi";
|
||||
import { resolver } from "hono-openapi/arktype";
|
||||
import { describeRoute, resolver } from "hono-openapi";
|
||||
|
||||
const volumeSchema = type({
|
||||
name: "string",
|
||||
@@ -12,7 +11,7 @@ const volumeSchema = type({
|
||||
createdAt: "number",
|
||||
updatedAt: "number",
|
||||
lastHealthCheck: "number",
|
||||
config: volumeConfigSchema,
|
||||
config: volumeConfigSchemaNoUndefined,
|
||||
autoRemount: "boolean",
|
||||
});
|
||||
|
||||
@@ -30,7 +29,6 @@ export const listVolumesDto = describeRoute({
|
||||
description: "List all volumes",
|
||||
tags: ["Volumes"],
|
||||
operationId: "listVolumes",
|
||||
validateResponse: true,
|
||||
responses: {
|
||||
200: {
|
||||
description: "A list of volumes",
|
||||
@@ -48,7 +46,7 @@ export const listVolumesDto = describeRoute({
|
||||
*/
|
||||
export const createVolumeBody = type({
|
||||
name: "string",
|
||||
config: volumeConfigSchema,
|
||||
config: volumeConfigSchemaNoUndefined,
|
||||
});
|
||||
|
||||
export const createVolumeResponse = type({
|
||||
@@ -62,7 +60,6 @@ export const createVolumeResponse = type({
|
||||
export const createVolumeDto = describeRoute({
|
||||
description: "Create a new volume",
|
||||
operationId: "createVolume",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
201: {
|
||||
@@ -86,7 +83,6 @@ export const deleteVolumeResponse = type({
|
||||
export const deleteVolumeDto = describeRoute({
|
||||
description: "Delete a volume",
|
||||
operationId: "deleteVolume",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
200: {
|
||||
@@ -118,7 +114,6 @@ export type GetVolumeResponseDto = typeof getVolumeResponse.infer;
|
||||
export const getVolumeDto = describeRoute({
|
||||
description: "Get a volume by name",
|
||||
operationId: "getVolume",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
200: {
|
||||
@@ -140,7 +135,7 @@ export const getVolumeDto = describeRoute({
|
||||
*/
|
||||
export const updateVolumeBody = type({
|
||||
autoRemount: "boolean?",
|
||||
config: volumeConfigSchema.optional(),
|
||||
config: volumeConfigSchemaNoUndefined.optional(),
|
||||
});
|
||||
|
||||
export type UpdateVolumeBody = typeof updateVolumeBody.infer;
|
||||
@@ -153,7 +148,6 @@ export const updateVolumeResponse = type({
|
||||
export const updateVolumeDto = describeRoute({
|
||||
description: "Update a volume's configuration",
|
||||
operationId: "updateVolume",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
200: {
|
||||
@@ -176,7 +170,7 @@ export type UpdateVolumeResponseDto = typeof updateVolumeResponse.infer;
|
||||
* Test connection
|
||||
*/
|
||||
export const testConnectionBody = type({
|
||||
config: volumeConfigSchema,
|
||||
config: volumeConfigSchemaNoUndefined,
|
||||
});
|
||||
|
||||
export const testConnectionResponse = type({
|
||||
@@ -187,7 +181,6 @@ export const testConnectionResponse = type({
|
||||
export const testConnectionDto = describeRoute({
|
||||
description: "Test connection to backend",
|
||||
operationId: "testConnection",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
200: {
|
||||
@@ -212,7 +205,6 @@ export const mountVolumeResponse = type({
|
||||
export const mountVolumeDto = describeRoute({
|
||||
description: "Mount a volume",
|
||||
operationId: "mountVolume",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
200: {
|
||||
@@ -240,7 +232,6 @@ export const unmountVolumeResponse = type({
|
||||
export const unmountVolumeDto = describeRoute({
|
||||
description: "Unmount a volume",
|
||||
operationId: "unmountVolume",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
200: {
|
||||
@@ -265,7 +256,6 @@ export const healthCheckResponse = type({
|
||||
export const healthCheckDto = describeRoute({
|
||||
description: "Perform a health check on a volume",
|
||||
operationId: "healthCheckVolume",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
200: {
|
||||
@@ -300,7 +290,6 @@ export type ListContainersResponseDto = typeof listContainersResponse.infer;
|
||||
export const getContainersDto = describeRoute({
|
||||
description: "Get containers using a volume by name",
|
||||
operationId: "getContainersUsingVolume",
|
||||
validateResponse: true,
|
||||
tags: ["Volumes"],
|
||||
responses: {
|
||||
200: {
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
"noImplicitOverride": true,
|
||||
"module": "preserve",
|
||||
"noEmit": true,
|
||||
"lib": ["es2022"],
|
||||
"paths": {
|
||||
"~/*": ["./src/*"]
|
||||
},
|
||||
"lib": ["es2022"]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user