mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(server): job discovery (#13838)
refactor(server): job discorvery
This commit is contained in:
parent
0130052de5
commit
5b2cd704d3
33 changed files with 323 additions and 376 deletions
|
|
@ -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}`;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue