This commit is contained in:
@@ -129,6 +129,7 @@ const getNodeWasmRoute = createRoute({
|
||||
nodeRouter.openapi(getNodeWasmRoute, async (c) => {
|
||||
const { user, system, nodeId } = c.req.valid("param");
|
||||
|
||||
const a = performance.now();
|
||||
const wasmContent = await service.getNodeWasmById(
|
||||
user,
|
||||
system,
|
||||
|
||||
@@ -110,6 +110,7 @@ export async function getNodeWasmById(
|
||||
systemId: string,
|
||||
nodeId: string,
|
||||
) {
|
||||
const a = performance.now();
|
||||
const node = await db.select({ content: nodeTable.content }).from(nodeTable)
|
||||
.where(
|
||||
and(
|
||||
@@ -117,7 +118,8 @@ export async function getNodeWasmById(
|
||||
eq(nodeTable.systemId, systemId),
|
||||
eq(nodeTable.nodeId, nodeId),
|
||||
),
|
||||
).limit(1);
|
||||
).limit(1).execute();
|
||||
console.log("Time to load wasm", performance.now() - a);
|
||||
|
||||
if (!node[0]) {
|
||||
throw new Error("Node not found");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
customType,
|
||||
index,
|
||||
integer,
|
||||
json,
|
||||
pgTable,
|
||||
@@ -27,7 +28,12 @@ export const nodeTable = pgTable("nodes", {
|
||||
definition: json().notNull(),
|
||||
hash: varchar({ length: 8 }).notNull(),
|
||||
previous: integer(),
|
||||
});
|
||||
}, (table) => [
|
||||
index("user_id_idx").on(table.userId),
|
||||
index("system_id_idx").on(table.systemId),
|
||||
index("node_id_idx").on(table.nodeId),
|
||||
index("hash_idx").on(table.hash),
|
||||
]);
|
||||
|
||||
export const nodeRelations = relations(nodeTable, ({ one }) => ({
|
||||
userId: one(usersTable, {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||
import { nodeRouter } from "./node/node.controller.ts";
|
||||
import { userRouter } from "./user/user.controller.ts";
|
||||
|
||||
const router = new OpenAPIHono();
|
||||
|
||||
router.route("nodes", nodeRouter);
|
||||
router.route("users", userRouter);
|
||||
|
||||
export { router };
|
||||
@@ -1,14 +1,6 @@
|
||||
import { pgTable, text, uuid } from "drizzle-orm/pg-core";
|
||||
import { z } from "@hono/zod-openapi";
|
||||
|
||||
export const usersTable = pgTable("users", {
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
name: text().unique().notNull(),
|
||||
});
|
||||
|
||||
export const UserSchema = z
|
||||
.object({
|
||||
id: z.string().uuid(),
|
||||
name: z.string().min(1), // Non-null text with a unique constraint (enforced at the database level)
|
||||
})
|
||||
.openapi("User");
|
||||
|
||||
8
store/src/routes/user/user.validation.ts
Normal file
8
store/src/routes/user/user.validation.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { z } from "@hono/zod-openapi";
|
||||
|
||||
export const UserSchema = z
|
||||
.object({
|
||||
id: z.string().uuid(),
|
||||
name: z.string().min(1),
|
||||
})
|
||||
.openapi("User");
|
||||
Reference in New Issue
Block a user