loom serve bootstrap
This commit is contained in:
parent
677c22d3a6
commit
30e97f5b8e
7 changed files with 470 additions and 50 deletions
37
platform/loom/cli/serve.ts
Normal file
37
platform/loom/cli/serve.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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",
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue