Merge pull request #45 from detleph/feature-endpoints

Add more endpoints
This commit is contained in:
Stephan
2022-05-03 14:58:01 +02:00
committed by GitHub
14 changed files with 498 additions and 11 deletions
+1
View File
@@ -1,6 +1,7 @@
export default class ForwardableError extends Error {
// If in different context
private readonly __id = "CUSTOM_ERROR";
protected readonly __oid?: string;
public readonly status: number;
+13
View File
@@ -0,0 +1,13 @@
import ForwardableError from "./ForwardableError";
export default class NotFoundError extends ForwardableError {
protected __oid = "NOT_FOUND_ERROR";
constructor(resource?: string, pid?: string) {
super(404, `The requested ${resource ?? "resource"}${pid ? ` with PID '${pid}'` : ""} could not be found!`);
}
static isNotFoundError(err: any): err is NotFoundError {
return err.__oid === "NOT_FOUND_ERROR";
}
}
+13
View File
@@ -0,0 +1,13 @@
import ForwardableError from "./ForwardableError";
export default class SchemaError extends ForwardableError {
protected __oid = "SCHEMA_ERROR";
constructor(message: string) {
super(400, message);
}
public static isSchemaError(err: any): err is SchemaError {
return err.__oid === "SCHEMA_ERROR";
}
}