This commit is contained in:
Michael Quigley 2025-03-04 13:35:44 -05:00
parent 56b8d1e92c
commit 8ca598ab3a
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 22 additions and 27 deletions

View File

@ -10,33 +10,29 @@ import {
ShareRequest
} from "@openziti/zrok";
const program = new Command();
program
.command("http-server")
.version("1.0.0")
.description("A simple HTTP server example, sharing directly to a zrok share")
.action(async () => {
let root = loadRoot();
await init(root)
.catch((err: Error) => {
console.log(err);
return process.exit(1);
});
let shr = await createShare(root, new ShareRequest(PUBLIC_SHARE_MODE, PROXY_BACKEND_MODE, "http-server"));
let app = express(shr);
app.get("/", (r: Request, res: any) => {
res.write("hello, world!\n");
res.end();
});
app.listen(undefined, () => {
console.log("listening at '" + shr.frontendEndpoints + "'");
const httpServer = async () => {
let root = loadRoot();
await init(root)
.catch((err: Error) => {
console.log(err);
return process.exit(1);
});
let shr = await createShare(root, new ShareRequest(PUBLIC_SHARE_MODE, PROXY_BACKEND_MODE, "http-server"));
process.on("SIGINT", async () => {
deleteShare(root, shr);
});
let app = express(shr);
app.get("/", (r: Request, res: any) => {
res.write("hello, world!\n");
res.end();
});
app.listen(undefined, () => {
console.log("listening at '" + shr.frontendEndpoints + "'");
});
process.on("SIGINT", async () => {
deleteShare(root, shr);
});
}
const program = new Command();
program.command("http-server").description("A simple HTTP server example, sharing directly to a zrok share").action(httpServer);
program.parse(process.argv);

View File

@ -13,8 +13,6 @@ import {
} from "@openziti/zrok";
import readlineSync = require('readline-sync');
const program = new Command();
const copyto = async () => {
let text = readlineSync.question("enter some text: ");
let root = loadRoot();
@ -36,5 +34,6 @@ const copyto = async () => {
});
}
const program = new Command();
program.command("copyto").version("1.0.0").description("serve a copy buffer").action(copyto);
program.parse(process.argv);