feat: Integrate setup behaviour

This adds options for enabling setup to the config folder.
All default configs with permanent storage (file/sparql)
are configured to require setup at server start.
Memory-based configs merely have it as an option.
This commit is contained in:
Joachim Van Herwegen
2021-09-15 16:56:18 +02:00
parent 4e1a2f5981
commit b592d449eb
47 changed files with 883 additions and 246 deletions

View File

@@ -317,6 +317,7 @@ export * from './util/handlers/BooleanHandler';
export * from './util/handlers/ConditionalHandler';
export * from './util/handlers/ParallelHandler';
export * from './util/handlers/SequenceHandler';
export * from './util/handlers/StaticHandler';
export * from './util/handlers/UnsupportedAsyncHandler';
export * from './util/handlers/WaterfallHandler';

View File

@@ -0,0 +1,22 @@
import { AsyncHandler } from './AsyncHandler';
/**
* A handler that always resolves and always returns the stored value.
* Will return undefined if no value is stored.
*
* The generic type extends `any` due to Components.js requirements.
*/
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
export class StaticHandler<T extends any = void> extends AsyncHandler<any, T> {
private readonly value?: T;
public constructor(value?: T) {
super();
this.value = value;
}
public async handle(): Promise<T> {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
return this.value!;
}
}