mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import type { HttpHandler,
|
|
ResourceStore } from '../../index';
|
|
import {
|
|
AllowEverythingAuthorizer,
|
|
AuthenticatedLdpHandler,
|
|
BasicResponseWriter,
|
|
MethodPermissionsExtractor,
|
|
UnsecureWebIdExtractor,
|
|
} from '../../index';
|
|
import type { ServerConfig } from './ServerConfig';
|
|
import { getOperationHandler, getInMemoryResourceStore, getBasicRequestParser } from './Util';
|
|
|
|
/**
|
|
* BasicConfig works with
|
|
* - an AllowEverythingAuthorizer (no acl)
|
|
* - an InMemoryResourceStore
|
|
* - GET, POST & DELETE operation handlers
|
|
*/
|
|
|
|
export class BasicConfig implements ServerConfig {
|
|
public store: ResourceStore;
|
|
|
|
public constructor() {
|
|
this.store = getInMemoryResourceStore();
|
|
}
|
|
|
|
public getHttpHandler(): HttpHandler {
|
|
const requestParser = getBasicRequestParser();
|
|
|
|
const credentialsExtractor = new UnsecureWebIdExtractor();
|
|
const permissionsExtractor = new MethodPermissionsExtractor();
|
|
const authorizer = new AllowEverythingAuthorizer();
|
|
|
|
const operationHandler = getOperationHandler(this.store);
|
|
|
|
const responseWriter = new BasicResponseWriter();
|
|
|
|
const handler = new AuthenticatedLdpHandler({
|
|
requestParser,
|
|
credentialsExtractor,
|
|
permissionsExtractor,
|
|
authorizer,
|
|
operationHandler,
|
|
responseWriter,
|
|
});
|
|
|
|
return handler;
|
|
}
|
|
}
|