1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

serve command (#451)

This commit is contained in:
Kyle Spearrin
2022-01-19 10:45:14 -05:00
committed by GitHub
parent 84a0bfb07c
commit 922cd1dc54
26 changed files with 2091 additions and 332 deletions

View File

@@ -1,5 +1,3 @@
import * as program from "commander";
import { CipherService } from "jslib-common/abstractions/cipher.service";
import { Response } from "jslib-node/cli/models/response";
@@ -7,20 +5,20 @@ import { Response } from "jslib-node/cli/models/response";
export class RestoreCommand {
constructor(private cipherService: CipherService) {}
async run(object: string, id: string, cmd: program.Command): Promise<Response> {
async run(object: string, id: string): Promise<Response> {
if (id != null) {
id = id.toLowerCase();
}
switch (object.toLowerCase()) {
case "item":
return await this.restoreCipher(id, cmd);
return await this.restoreCipher(id);
default:
return Response.badRequest("Unknown object.");
}
}
private async restoreCipher(id: string, cmd: program.Command) {
private async restoreCipher(id: string) {
const cipher = await this.cipherService.get(id);
if (cipher == null) {
return Response.notFound();