feat: some stuff
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m0s
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m0s
This commit is contained in:
parent
15ff1cc52d
commit
dc46c4b64c
@ -45,6 +45,7 @@ async function postNode(node: Node) {
|
|||||||
const wasmContent = await Deno.readFile(node.path);
|
const wasmContent = await Deno.readFile(node.path);
|
||||||
|
|
||||||
const url = `http://localhost:8000/nodes`;
|
const url = `http://localhost:8000/nodes`;
|
||||||
|
// const url = "https://node-store.app.max-richter.dev/nodes";
|
||||||
|
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -58,34 +58,16 @@ async function getNodeByVersion(
|
|||||||
const [id, version] = nodeId.replace(/\.wasm$/, "").split("@");
|
const [id, version] = nodeId.replace(/\.wasm$/, "").split("@");
|
||||||
console.log({ user, system, id, version });
|
console.log({ user, system, id, version });
|
||||||
if (version) {
|
if (version) {
|
||||||
return service.getNodeVersionWasm(
|
return service.getNodeVersionWasm(user, system, id, version);
|
||||||
user,
|
|
||||||
system,
|
|
||||||
id,
|
|
||||||
version,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return service.getNodeWasmById(
|
return service.getNodeWasmById(user, system, id);
|
||||||
user,
|
|
||||||
system,
|
|
||||||
id,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const [id, version] = nodeId.replace(/\.json$/, "").split("@");
|
const [id, version] = nodeId.replace(/\.json$/, "").split("@");
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return service.getNodeDefinitionById(
|
return service.getNodeDefinitionById(user, system, id);
|
||||||
user,
|
|
||||||
system,
|
|
||||||
id,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return await service.getNodeVersion(
|
return await service.getNodeVersion(user, system, id, version);
|
||||||
user,
|
|
||||||
system,
|
|
||||||
id,
|
|
||||||
version,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +152,10 @@ nodeRouter.openapi(
|
|||||||
console.log("Get Nodes by System", { user, system });
|
console.log("Get Nodes by System", { user, system });
|
||||||
try {
|
try {
|
||||||
const nodes = await service.getNodesBySystem(user, system);
|
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) {
|
} catch (error) {
|
||||||
if (error instanceof CustomError) {
|
if (error instanceof CustomError) {
|
||||||
throw new HTTPException(error.status, { message: error.message });
|
throw new HTTPException(error.status, { message: error.message });
|
||||||
@ -201,8 +186,13 @@ nodeRouter.openapi(
|
|||||||
const nodeId = c.req.param("nodeId.json").replace(/\.json$/, "");
|
const nodeId = c.req.param("nodeId.json").replace(/\.json$/, "");
|
||||||
console.log("Get Node by Id", { user, system, nodeId });
|
console.log("Get Node by Id", { user, system, nodeId });
|
||||||
try {
|
try {
|
||||||
const node = await service.getNodeDefinitionById(user, system, nodeId);
|
const res = await getNodeByVersion(user, system, nodeId);
|
||||||
return c.json(node);
|
if (res instanceof ArrayBuffer) {
|
||||||
|
c.header("Content-Type", "application/wasm");
|
||||||
|
return c.body(res);
|
||||||
|
} else {
|
||||||
|
return c.json(res);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof CustomError) {
|
if (error instanceof CustomError) {
|
||||||
throw new HTTPException(error.status, { message: error.message });
|
throw new HTTPException(error.status, { message: error.message });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user