@freestyle-sh/with-dev-server
v0.1.8
Published
Node.js runtime via [NVM](https://github.com/nvm-sh/nvm) for [Freestyle](https://freestyle.sh) VMs.
Readme
@freestyle-sh/with-nodejs
Node.js runtime via NVM for Freestyle VMs.
Installation
npm install @freestyle-sh/with-nodejs freestyle-sandboxesUsage
import { freestyle, VmSpec } from "freestyle-sandboxes";
import { VmDevServer } from "../src/index";
import { VmPtySession } from "@freestyle-sh/with-pty";
const TEMPLATE_REPO = "https://github.com/freestyle-sh/freestyle-next";
const { repoId } = await freestyle.git.repos.create({
source: {
url: TEMPLATE_REPO,
},
});
const domain = `${repoId}.style.dev`;
const devPty = new VmPtySession({ sessionId: "dev-server" });
const { vm } = await freestyle.vms.create({
snapshot: new VmSpec({
with: {
devPty,
devServer: new VmDevServer({
workdir: "/repo",
templateRepo: TEMPLATE_REPO,
devCommand: "npm run dev",
devCommandPty: devPty,
}),
},
}),
with: {
devServer: new VmDevServer({
repo: repoId,
}),
},
domains: [
{
domain: domain,
vmPort: 3000,
},
],
});
