mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
24 lines
612 B
TypeScript
24 lines
612 B
TypeScript
import { AsyncHandler } from '../../src/util/handlers/AsyncHandler';
|
|
|
|
export class StaticAsyncHandler<TOut> extends AsyncHandler<any, TOut> {
|
|
private readonly canHandleStatic: boolean;
|
|
private readonly handleStatic: TOut;
|
|
|
|
public constructor(canHandleStatic: boolean, handleStatic: TOut) {
|
|
super();
|
|
this.canHandleStatic = canHandleStatic;
|
|
this.handleStatic = handleStatic;
|
|
}
|
|
|
|
public async canHandle(): Promise<void> {
|
|
if (this.canHandleStatic) {
|
|
return;
|
|
}
|
|
throw new Error('Not supported');
|
|
}
|
|
|
|
public async handle(): Promise<TOut> {
|
|
return this.handleStatic;
|
|
}
|
|
}
|