refactor(server): job discovery (#13838)

refactor(server): job discorvery
This commit is contained in:
Jason Rasmussen 2024-10-31 13:42:58 -04:00 committed by GitHub
parent 0130052de5
commit 5b2cd704d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 323 additions and 376 deletions

View file

@ -15,6 +15,32 @@ import { CLIP_MODEL_INFO, serverVersion } from 'src/constants';
import { ImmichCookie, ImmichHeader, MetadataKey } from 'src/enum';
import { ILoggerRepository } from 'src/interfaces/logger.interface';
export class ImmichStartupError extends Error {}
export const isStartUpError = (error: unknown): error is ImmichStartupError => error instanceof ImmichStartupError;
export const getKeyByValue = (object: Record<string, unknown>, value: unknown) =>
Object.keys(object).find((key) => object[key] === value);
export const getMethodNames = (instance: any) => {
const ctx = Object.getPrototypeOf(instance);
const methods: string[] = [];
for (const property of Object.getOwnPropertyNames(ctx)) {
const descriptor = Object.getOwnPropertyDescriptor(ctx, property);
if (!descriptor || descriptor.get || descriptor.set) {
continue;
}
const handler = instance[property];
if (typeof handler !== 'function') {
continue;
}
methods.push(property);
}
return methods;
};
export const getExternalDomain = (server: SystemConfig['server'], port: number) =>
server.externalDomain || `http://localhost:${port}`;