mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: add additional supported interfaces
This includes the relevant auth headers and a simplification of several others.
This commit is contained in:
17
src/util/AsyncHandler.ts
Normal file
17
src/util/AsyncHandler.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Simple interface for classes that can potentially handle a specific kind of data asynchronously.
|
||||
*/
|
||||
export interface AsyncHandler<TInput, TOutput = void> {
|
||||
/**
|
||||
* Checks if the input data can be handled by this class.
|
||||
* @param input - Input data that would be handled potentially.
|
||||
* @returns A promise resolving to if this input can be handled.
|
||||
*/
|
||||
canHandle: (input: TInput) => Promise<boolean>;
|
||||
/**
|
||||
* Handles the given input. This should only be done if the {@link canHandle} function returned `true`.
|
||||
* @param input - Input data that needs to be handled.
|
||||
* @returns A promise resolving when the handling is finished. Return value depends on the given type.
|
||||
*/
|
||||
handle: (input: TInput) => Promise<TOutput>;
|
||||
}
|
||||
Reference in New Issue
Block a user