feat(silo): added in charts and historical data
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {z, createRoute, OpenAPIHono} from "@hono/zod-openapi";
|
||||
import {modules} from "../../../../../database/schema/modules.js";
|
||||
import {db} from "../../../../../database/dbclient.js";
|
||||
import { z, createRoute, OpenAPIHono } from "@hono/zod-openapi";
|
||||
import { modules } from "../../../../../database/schema/modules.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { desc } from "drizzle-orm";
|
||||
|
||||
// Define the request body schema
|
||||
const requestSchema = z.object({
|
||||
@@ -13,10 +14,16 @@ const requestSchema = z.object({
|
||||
// Define the response schema
|
||||
const responseSchema = z.object({
|
||||
message: z.string().optional(),
|
||||
module_id: z.string().openapi({example: "6c922c6c-7de3-4ec4-acb0-f068abdc"}).optional(),
|
||||
name: z.string().openapi({example: "Production"}).optional(),
|
||||
active: z.boolean().openapi({example: true}).optional(),
|
||||
roles: z.string().openapi({example: `["viewer","technician"]`}).optional(),
|
||||
module_id: z
|
||||
.string()
|
||||
.openapi({ example: "6c922c6c-7de3-4ec4-acb0-f068abdc" })
|
||||
.optional(),
|
||||
name: z.string().openapi({ example: "Production" }).optional(),
|
||||
active: z.boolean().openapi({ example: true }).optional(),
|
||||
roles: z
|
||||
.string()
|
||||
.openapi({ example: `["viewer","technician"]` })
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
@@ -30,7 +37,7 @@ app.openapi(
|
||||
responses: {
|
||||
200: {
|
||||
content: {
|
||||
"application/json": {schema: responseSchema},
|
||||
"application/json": { schema: responseSchema },
|
||||
},
|
||||
description: "Response message",
|
||||
},
|
||||
@@ -40,7 +47,7 @@ app.openapi(
|
||||
//console.log("system modules");
|
||||
let module: any = [];
|
||||
try {
|
||||
module = await db.select().from(modules); // .where(eq(modules.active, true));
|
||||
module = await db.select().from(modules).orderBy(modules.name); // .where(eq(modules.active, true));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
module = [];
|
||||
@@ -49,7 +56,7 @@ app.openapi(
|
||||
// parse the roles
|
||||
const updateModules = module.map((m: any) => {
|
||||
if (m.roles) {
|
||||
return {...m, roles: m?.roles};
|
||||
return { ...m, roles: m?.roles };
|
||||
}
|
||||
return m;
|
||||
}); //JSON.parse(module[0]?.roles);
|
||||
|
||||
@@ -47,7 +47,10 @@ app.openapi(
|
||||
//console.log("system modules");
|
||||
let module: any = [];
|
||||
try {
|
||||
module = await db.select().from(subModules); // .where(eq(modules.active, true));
|
||||
module = await db
|
||||
.select()
|
||||
.from(subModules)
|
||||
.orderBy(subModules.name); // .where(eq(modules.active, true));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
module = [];
|
||||
|
||||
Reference in New Issue
Block a user