mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
[AC-2740] Add device-approval to bw serve (#9512)
* Extract bw serve endpoint configuration to a configurator class * Add device-approval endpoints to bw serve
This commit is contained in:
49
apps/cli/src/serve.program.ts
Normal file
49
apps/cli/src/serve.program.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { program } from "commander";
|
||||
|
||||
import { BaseProgram } from "./base-program";
|
||||
import { ServeCommand } from "./commands/serve.command";
|
||||
import { OssServeConfigurator } from "./oss-serve-configurator";
|
||||
import { ServiceContainer } from "./service-container";
|
||||
import { CliUtils } from "./utils";
|
||||
|
||||
const writeLn = CliUtils.writeLn;
|
||||
|
||||
export class ServeProgram extends BaseProgram {
|
||||
constructor(
|
||||
serviceContainer: ServiceContainer,
|
||||
private configurator: OssServeConfigurator,
|
||||
) {
|
||||
super(serviceContainer);
|
||||
}
|
||||
|
||||
register() {
|
||||
program
|
||||
.command("serve")
|
||||
.description("Start a RESTful API webserver.")
|
||||
.option("--hostname <hostname>", "The hostname to bind your API webserver to.")
|
||||
.option("--port <port>", "The port to run your API webserver on.")
|
||||
.option(
|
||||
"--disable-origin-protection",
|
||||
"If set, allows requests with origin header. Warning, this option exists for backwards compatibility reasons and exposes your environment to known CSRF attacks.",
|
||||
)
|
||||
.on("--help", () => {
|
||||
writeLn("\n Notes:");
|
||||
writeLn("");
|
||||
writeLn(" Default hostname is `localhost`.");
|
||||
writeLn(" Use hostname `all` for no hostname binding.");
|
||||
writeLn(" Default port is `8087`.");
|
||||
writeLn("");
|
||||
writeLn(" Examples:");
|
||||
writeLn("");
|
||||
writeLn(" bw serve");
|
||||
writeLn(" bw serve --port 8080");
|
||||
writeLn(" bw serve --hostname bwapi.mydomain.com --port 80");
|
||||
writeLn("", true);
|
||||
})
|
||||
.action(async (cmd) => {
|
||||
await this.exitIfNotAuthed();
|
||||
const command = new ServeCommand(this.serviceContainer, this.configurator);
|
||||
await command.run(cmd);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user