server/utils/lib.ts
2025-08-21 00:45:58 +02:00

15 lines
460 B
TypeScript

type ElementWithId = { id: string };
export const mergeAndDeduplicate = <T extends ElementWithId>(
...elements: T[][]
): T[] =>
elements
.reduce((acc, val) => acc.concat(val), [])
.filter(
(element, index, self) =>
index === self.findIndex((t) => t.id === element.id),
);
export const oauthRedirectUri = (baseUrl: URL, issuer: string): URL =>
new URL(`/oauth/sso/${issuer}/callback`, baseUrl);