Add PATCH /users/:userID endpoint

This commit is contained in:
zkldi
2021-08-22 06:07:43 +01:00
parent 48a98b2ae1
commit 466b2dd64e
9 changed files with 363 additions and 8 deletions
+21 -1
View File
@@ -75,4 +75,24 @@ export function IsString(val: unknown): val is string {
export function DedupeArr<T>(arr: T[]): T[] {
return [...new Set(arr)];
}
}
export function StripUrl(url: string, userInput: string | null) {
if (!userInput) {
return userInput;
}
if (userInput.toLowerCase().includes(url)) {
return userInput.split(url)[1];
}
return userInput;
}
export function DeleteUndefinedProps(record: any) {
for (const key in record) {
if (record[key] === undefined) {
delete record[key];
}
}
}
+2
View File
@@ -11,3 +11,5 @@ export function FormatPrError(err: PrudenceError, foreword = "Error") {
}
export const optNull = (v: ValidSchemaValue) => p.optional(p.nullable(v));
export const optNullFluffStrField = optNull(p.isBoundedString(3, 140));