1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-23 11:43:51 +00:00

Run prettier in feature branch

This commit is contained in:
Thomas Rittson
2021-12-17 06:09:55 +10:00
parent 44b0d51336
commit 1acfa54f00
593 changed files with 47237 additions and 42401 deletions

View File

@@ -1,45 +1,50 @@
import { BaseResponse } from './response/baseResponse';
import { BaseResponse } from "./response/baseResponse";
export class Response {
static error(error: any, data?: any): Response {
const res = new Response();
res.success = false;
if (typeof (error) === 'string') {
res.message = error;
} else {
res.message = error.message != null ? error.message :
error.toString() === '[object Object]' ? JSON.stringify(error) : error.toString();
}
res.data = data;
return res;
static error(error: any, data?: any): Response {
const res = new Response();
res.success = false;
if (typeof error === "string") {
res.message = error;
} else {
res.message =
error.message != null
? error.message
: error.toString() === "[object Object]"
? JSON.stringify(error)
: error.toString();
}
res.data = data;
return res;
}
static notFound(): Response {
return Response.error('Not found.');
}
static notFound(): Response {
return Response.error("Not found.");
}
static badRequest(message: string): Response {
return Response.error(message);
}
static badRequest(message: string): Response {
return Response.error(message);
}
static multipleResults(ids: string[]): Response {
let msg = 'More than one result was found. Try getting a specific object by `id` instead. ' +
'The following objects were found:';
ids.forEach(id => {
msg += '\n' + id;
});
return Response.error(msg, ids);
}
static multipleResults(ids: string[]): Response {
let msg =
"More than one result was found. Try getting a specific object by `id` instead. " +
"The following objects were found:";
ids.forEach((id) => {
msg += "\n" + id;
});
return Response.error(msg, ids);
}
static success(data?: BaseResponse): Response {
const res = new Response();
res.success = true;
res.data = data;
return res;
}
static success(data?: BaseResponse): Response {
const res = new Response();
res.success = true;
res.data = data;
return res;
}
success: boolean;
message: string;
errorCode: number;
data: BaseResponse;
success: boolean;
message: string;
errorCode: number;
data: BaseResponse;
}