1
0
silverbullet/packages/server/server.ts

31 lines
779 B
TypeScript
Raw Normal View History

2022-03-27 07:55:29 +00:00
#!/usr/bin/env node
import yargs from "yargs";
2022-04-01 15:32:03 +00:00
import { hideBin } from "yargs/helpers";
import { ExpressServer } from "./api_server";
2022-04-25 08:33:38 +00:00
import { nodeModulesDir } from "@plugos/plugos/environments/node_sandbox";
let args = yargs(hideBin(process.argv))
2022-04-01 15:32:03 +00:00
.option("port", {
type: "number",
default: 3000,
})
.parse();
2022-03-27 07:55:29 +00:00
if (!args._.length) {
2022-04-01 15:32:03 +00:00
console.error("Usage: silverbullet <path-to-pages>");
process.exit(1);
2022-03-27 07:55:29 +00:00
}
2022-03-21 14:21:34 +00:00
const pagesPath = args._[0] as string;
const port = args.port;
2022-04-25 08:33:38 +00:00
const webappDistDir = `${nodeModulesDir}/node_modules/@silverbulletmd/web/dist`;
2022-04-25 08:33:38 +00:00
// console.log("This is where the static files live", webappDistDir);
const expressServer = new ExpressServer(port, pagesPath, webappDistDir);
2022-04-24 16:06:34 +00:00
expressServer.start().catch((e) => {
console.error(e);
});