mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: support inrupt coding standards
This commit is contained in:
25
src/ldp/operations/Operation.ts
Normal file
25
src/ldp/operations/Operation.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Representation } from '../http/Representation';
|
||||
import { RepresentationPreferences } from '../http/RepresentationPreferences';
|
||||
import { ResourceIdentifier } from '../http/ResourceIdentifier';
|
||||
|
||||
/**
|
||||
* A single REST operation.
|
||||
*/
|
||||
export interface Operation {
|
||||
/**
|
||||
* The HTTP method (GET/POST/PUT/PATCH/DELETE/etc.).
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* Identifier of the target.
|
||||
*/
|
||||
target: ResourceIdentifier;
|
||||
/**
|
||||
* Representation preferences of the response. Will be empty if there are none.
|
||||
*/
|
||||
preferences: RepresentationPreferences;
|
||||
/**
|
||||
* Optional representation of the body.
|
||||
*/
|
||||
body?: Representation;
|
||||
}
|
||||
21
src/ldp/operations/OperationHandler.ts
Normal file
21
src/ldp/operations/OperationHandler.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Operation } from './Operation';
|
||||
|
||||
/**
|
||||
* Handler for a specific operation type.
|
||||
*/
|
||||
export interface OperationHandler {
|
||||
/**
|
||||
* Checks if the handler supports the given operation.
|
||||
* @param operation - The input operation.
|
||||
*
|
||||
* @returns A promise resolving to a boolean indicating if this handler supports the operation.
|
||||
*/
|
||||
canHandle: (operation: Operation) => Promise<boolean>;
|
||||
/**
|
||||
* Handles the given operation.
|
||||
* @param operation - The input operation.
|
||||
*
|
||||
* @returns A promise resolving when the operation is handled.
|
||||
*/
|
||||
handle: (operation: Operation) => Promise<void>;
|
||||
}
|
||||
Reference in New Issue
Block a user