gr-base/platform/loom/cli/serve.ts
2025-10-06 14:19:00 +07:00

37 lines
893 B
TypeScript

import { buildCommand, numberParser } from "npm:@stricli/core";
import express from 'npm:express';
type Flags = {
readonly port?: number;
};
export const command = buildCommand({
func: async (flags: Flags, _text: string) => {
const port = flags.port ?? 8066;
const hostname = "localhost";
console.debug(
`Requested an interactive editor server at http://${hostname}:${port}`,
);
const app = express();
app.use(express.static(import.meta.dirname + '/../editor/dist'));
app.listen(port, hostname, () => {
console.debug(`Express server running at http://${hostname}:${port}`);
});
},
parameters: {
flags: {
port: {
brief: "Port to run the editor server on",
kind: "parsed",
parse: numberParser,
optional: true,
},
}
},
docs: {
brief: "Run an interactive editor server",
},
});