import { transform } from "esbuild"; import { apiContext } from "service-srv"; export const _ = { url: "/code_build", async api(arg: Record) { // const { req, res } = apiContext(this); const result = {} as Record; await Promise.all( Object.entries(arg).map(async ([key, src]) => { const res = await transform(`return ${src}`, { jsx: "transform", format: "cjs", loader: "tsx", }); result[key] = res.code.substring(6); }) ); return result; }, };