feat: better types

This commit is contained in:
Taylor Schley
2022-02-22 15:50:08 -06:00
parent ea5aceedfd
commit 9e0fee5f00
+11 -7
View File
@@ -58,11 +58,11 @@ declare class Bree extends EventEmitter {
}
declare namespace Bree {
interface JobOptions {
name?: string;
path?: string | (() => void);
timeout?: number | string | boolean;
interval?: number | string;
interface Job {
name: string;
path: string | (() => void);
timeout: number | string | boolean;
interval: number | string;
date?: Date;
cron?: string;
hasSeconds?: boolean;
@@ -73,6 +73,8 @@ declare namespace Bree {
timezone?: string;
}
type JobOptions = Required<Pick<Job, 'name'>> & Partial<Omit<Job, 'name'>>;
interface BreeConfigs {
logger: Record<string, unknown>;
root: string | boolean;
@@ -82,7 +84,7 @@ declare namespace Bree {
timeout: number | boolean;
interval: number;
timezone: string;
jobs: Array<string | (() => void) | JobOptions>;
jobs: JobOptions[];
hasSeconds: boolean;
cronValidate: Record<string, unknown>;
closeWorkerAfterMs: number;
@@ -94,7 +96,9 @@ declare namespace Bree {
outputWorkerMetadata: boolean;
}
type BreeOptions = Partial<BreeConfigs>;
type BreeOptions = Partial<BreeConfigs> & {
jobs?: Array<string | (() => void) | JobOptions>;
};
type PluginFunc<T = unknown> = (options: T, c: typeof Bree) => void;