Compare commits

..

7 Commits

Author SHA1 Message Date
05b192e7ab commit to trigger deploy 2025-01-15 19:30:12 +01:00
edcaab4bd4 fix: use correct url 2025-01-15 18:17:04 +01:00
a99040f42e feat: some shit
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 47s
2024-12-20 16:35:23 +01:00
fca59e87e5 feat: some shit 2024-12-20 16:35:16 +01:00
05e8970475 feat: use remote registry
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m4s
2024-12-20 16:11:30 +01:00
385d1dd831 feat: use remote registry
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m2s
2024-12-20 16:06:18 +01:00
dc46c4b64c feat: some stuff
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m0s
2024-12-20 15:55:45 +01:00
4 changed files with 96 additions and 93 deletions

View File

@ -32,7 +32,10 @@
let performanceStore = createPerformanceStore();
const registryCache = new IndexDBCache("node-registry");
const nodeRegistry = new RemoteNodeRegistry("", registryCache);
const nodeRegistry = new RemoteNodeRegistry(
"https://node-store.app.max-richter.dev",
registryCache,
);
const workerRuntime = new WorkerRuntimeExecutor();
const runtimeCache = new MemoryRuntimeCache();
const memoryRuntime = new MemoryRuntimeExecutor(nodeRegistry, runtimeCache);

View File

@ -45,6 +45,7 @@ async function postNode(node: Node) {
const wasmContent = await Deno.readFile(node.path);
const url = `http://localhost:8000/nodes`;
// const url = "https://node-store.app.max-richter.dev/nodes";
const res = await fetch(url, {
method: "POST",

View File

@ -58,34 +58,16 @@ async function getNodeByVersion(
const [id, version] = nodeId.replace(/\.wasm$/, "").split("@");
console.log({ user, system, id, version });
if (version) {
return service.getNodeVersionWasm(
user,
system,
id,
version,
);
return service.getNodeVersionWasm(user, system, id, version);
} else {
return service.getNodeWasmById(
user,
system,
id,
);
return service.getNodeWasmById(user, system, id);
}
} else {
const [id, version] = nodeId.replace(/\.json$/, "").split("@");
if (!version) {
return service.getNodeDefinitionById(
user,
system,
id,
);
return service.getNodeDefinitionById(user, system, id);
} else {
return await service.getNodeVersion(
user,
system,
id,
version,
);
return await service.getNodeVersion(user, system, id, version);
}
}
}
@ -170,7 +152,10 @@ nodeRouter.openapi(
console.log("Get Nodes by System", { user, system });
try {
const nodes = await service.getNodesBySystem(user, system);
return c.json(nodes);
return c.json({
id: `${user}/${system}`,
nodes: nodes.map((n) => ({ id: n.id.split("@")[0] })),
});
} catch (error) {
if (error instanceof CustomError) {
throw new HTTPException(error.status, { message: error.message });
@ -201,8 +186,13 @@ nodeRouter.openapi(
const nodeId = c.req.param("nodeId.json").replace(/\.json$/, "");
console.log("Get Node by Id", { user, system, nodeId });
try {
const node = await service.getNodeDefinitionById(user, system, nodeId);
return c.json(node);
const res = await getNodeByVersion(user, system, nodeId);
if (res instanceof ArrayBuffer) {
c.header("Content-Type", "application/wasm");
return c.body(res);
} else {
return c.json(res);
}
} catch (error) {
if (error instanceof CustomError) {
throw new HTTPException(error.status, { message: error.message });

View File

@ -53,21 +53,17 @@ export async function createNode(
}
export async function getNodeDefinitionsByUser(userName: string) {
const nodes = await db.select({
const nodes = await db
.select({
definition: nodeTable.definition,
hash: nodeTable.hash,
}).from(
nodeTable,
)
.where(
and(
eq(nodeTable.userId, userName),
),
);
})
.from(nodeTable)
.where(and(eq(nodeTable.userId, userName)));
return nodes.map((n) => ({
...n.definition,
id: n.definition.id + "@" + n.hash,
// id: n.definition.id + "@" + n.hash,
}));
}
@ -83,16 +79,18 @@ export async function getNodesBySystem(
.from(nodeTable)
.where(
and(eq(nodeTable.systemId, systemId), eq(nodeTable.userId, username)),
).orderBy(nodeTable.userId, nodeTable.systemId, nodeTable.nodeId);
)
.orderBy(nodeTable.userId, nodeTable.systemId, nodeTable.nodeId);
const definitions = nodes
.map((node) =>
[NodeDefinitionSchema.safeParse(node.definition), node.hash] as const
.map(
(node) =>
[NodeDefinitionSchema.safeParse(node.definition), node.hash] as const,
)
.filter(([v]) => v.success)
.map(([v, hash]) => ({
...v.data,
id: v?.data?.id + "@" + hash,
// id: v?.data?.id + "@" + hash,
}));
return definitions;
@ -103,7 +101,9 @@ export async function getNodeWasmById(
systemId: string,
nodeId: string,
) {
const node = await db.select({ content: nodeTable.content }).from(nodeTable)
const node = await db
.select({ content: nodeTable.content })
.from(nodeTable)
.where(
and(
eq(nodeTable.userId, userName),
@ -126,12 +126,13 @@ export async function getNodeDefinitionById(
systemId: string,
nodeId: string,
) {
const node = await db.select({
const node = await db
.select({
definition: nodeTable.definition,
hash: nodeTable.hash,
}).from(
nodeTable,
).where(
})
.from(nodeTable)
.where(
and(
eq(nodeTable.userId, userName),
eq(nodeTable.systemId, systemId),
@ -151,7 +152,10 @@ export async function getNodeDefinitionById(
throw new InvalidNodeDefinitionError();
}
return { ...definition.data, id: definition.data.id + "@" + node[0].hash };
return {
...definition.data,
// id: definition.data.id + "@" + node[0].hash
};
}
export async function getNodeVersions(
@ -159,12 +163,13 @@ export async function getNodeVersions(
system: string,
nodeId: string,
) {
const nodes = await db.select({
const nodes = await db
.select({
definition: nodeTable.definition,
hash: nodeTable.hash,
}).from(
nodeTable,
).where(
})
.from(nodeTable)
.where(
and(
eq(nodeTable.userId, user),
eq(nodeTable.systemId, system),
@ -175,7 +180,7 @@ export async function getNodeVersions(
return nodes.map((node) => ({
...node.definition,
id: node.definition.id + "@" + node.hash,
// id: node.definition.id + "@" + node.hash,
}));
}
@ -185,18 +190,20 @@ export async function getNodeVersion(
nodeId: string,
hash: string,
) {
const nodes = await db.select({
const nodes = await db
.select({
definition: nodeTable.definition,
}).from(
nodeTable,
).where(
})
.from(nodeTable)
.where(
and(
eq(nodeTable.userId, user),
eq(nodeTable.systemId, system),
eq(nodeTable.nodeId, nodeId),
eq(nodeTable.hash, hash),
),
).limit(1);
)
.limit(1);
if (nodes.length === 0) {
throw new NodeNotFoundError();
@ -211,18 +218,20 @@ export async function getNodeVersionWasm(
nodeId: string,
hash: string,
) {
const node = await db.select({
const node = await db
.select({
content: nodeTable.content,
}).from(
nodeTable,
).where(
})
.from(nodeTable)
.where(
and(
eq(nodeTable.userId, user),
eq(nodeTable.systemId, system),
eq(nodeTable.nodeId, nodeId),
eq(nodeTable.hash, hash),
),
).limit(1);
)
.limit(1);
if (node.length === 0) {
throw new NodeNotFoundError();