37 lines
925 B
TypeScript
37 lines
925 B
TypeScript
import type { IRequestContext, IResponse, IAuthToken } from './interfaces.core.js';
|
|
|
|
/**
|
|
* Abstract base class for all registry protocol implementations
|
|
*/
|
|
export abstract class BaseRegistry {
|
|
/**
|
|
* Initialize the registry
|
|
*/
|
|
abstract init(): Promise<void>;
|
|
|
|
/**
|
|
* Handle an incoming HTTP request
|
|
* @param context - Request context
|
|
* @returns Response object
|
|
*/
|
|
abstract handleRequest(context: IRequestContext): Promise<IResponse>;
|
|
|
|
/**
|
|
* Get the base path for this registry protocol
|
|
*/
|
|
abstract getBasePath(): string;
|
|
|
|
/**
|
|
* Validate that a token has the required permissions
|
|
* @param token - Authentication token
|
|
* @param resource - Resource being accessed
|
|
* @param action - Action being performed
|
|
* @returns true if authorized
|
|
*/
|
|
protected abstract checkPermission(
|
|
token: IAuthToken | null,
|
|
resource: string,
|
|
action: string
|
|
): Promise<boolean>;
|
|
}
|