chore: cleanup node buildscripts
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { createWasmWrapper } from "@nodarium/utils";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { createWasmWrapper } from '@nodarium/utils';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
export async function getWasm(id: `${string}/${string}/${string}`) {
|
||||
const filePath = path.resolve(`../nodes/${id}/pkg/node.wasm`);
|
||||
const filePath = path.resolve(`./static/nodes/${id}`);
|
||||
console.log({ filePath });
|
||||
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
@@ -36,12 +37,12 @@ export async function getNode(id: `${string}/${string}/${string}`) {
|
||||
}
|
||||
|
||||
export async function getCollectionNodes(userId: `${string}/${string}`) {
|
||||
const nodes = await fs.readdir(path.resolve(`../nodes/${userId}`));
|
||||
const nodes = await fs.readdir(path.resolve(`./static/nodes/${userId}`));
|
||||
return nodes
|
||||
.filter((n) => n !== "pkg" && n !== ".template")
|
||||
.filter((n) => n !== 'pkg' && n !== '.template')
|
||||
.map((n) => {
|
||||
return {
|
||||
id: `${userId}/${n}`,
|
||||
id: `${userId}/${n}`
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -50,20 +51,20 @@ export async function getCollection(userId: `${string}/${string}`) {
|
||||
const nodes = await getCollectionNodes(userId);
|
||||
return {
|
||||
id: userId,
|
||||
nodes,
|
||||
nodes
|
||||
};
|
||||
}
|
||||
|
||||
export async function getUserCollections(userId: string) {
|
||||
const collections = await fs.readdir(path.resolve(`../nodes/${userId}`));
|
||||
const collections = await fs.readdir(path.resolve(`./static/nodes/${userId}`));
|
||||
return Promise.all(
|
||||
collections.map(async (n) => {
|
||||
const nodes = await getCollectionNodes(`${userId}/${n}`);
|
||||
return {
|
||||
id: `${userId}/${n}`,
|
||||
nodes,
|
||||
nodes
|
||||
};
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,20 +72,20 @@ export async function getUser(userId: string) {
|
||||
const collections = await getUserCollections(userId);
|
||||
return {
|
||||
id: userId,
|
||||
collections,
|
||||
collections
|
||||
};
|
||||
}
|
||||
|
||||
export async function getUsers() {
|
||||
const nodes = await fs.readdir(path.resolve("../nodes"));
|
||||
const nodes = await fs.readdir(path.resolve('./static/nodes'));
|
||||
const users = await Promise.all(
|
||||
nodes.map(async (n) => {
|
||||
const collections = await getUserCollections(n);
|
||||
return {
|
||||
id: n,
|
||||
collections,
|
||||
collections
|
||||
};
|
||||
}),
|
||||
})
|
||||
);
|
||||
return users;
|
||||
}
|
||||
|
||||
1
app/static/.gitignore
vendored
Normal file
1
app/static/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
nodes/
|
||||
Reference in New Issue
Block a user