mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: add documentation for many classes where it was missing
This commit is contained in:
@@ -2,4 +2,7 @@ import { AsyncHandler } from '../../util/AsyncHandler';
|
||||
import { HttpRequest } from '../../server/HttpRequest';
|
||||
import { Representation } from '../representation/Representation';
|
||||
|
||||
/**
|
||||
* Parses the body of an incoming {@link HttpRequest} and converts it to a {@link Representation}.
|
||||
*/
|
||||
export abstract class BodyParser extends AsyncHandler<HttpRequest, Representation> {}
|
||||
|
||||
@@ -2,4 +2,7 @@ import { AsyncHandler } from '../../util/AsyncHandler';
|
||||
import { HttpRequest } from '../../server/HttpRequest';
|
||||
import { RepresentationPreferences } from '../representation/RepresentationPreferences';
|
||||
|
||||
/**
|
||||
* Creates {@link RepresentationPreferences} based on the incoming HTTP headers in a {@link HttpRequest}.
|
||||
*/
|
||||
export abstract class PreferenceParser extends AsyncHandler<HttpRequest, RepresentationPreferences> {}
|
||||
|
||||
@@ -5,6 +5,10 @@ import { RepresentationMetadata } from '../representation/RepresentationMetadata
|
||||
import { StreamParser } from 'n3';
|
||||
import { UnsupportedMediaTypeHttpError } from '../../util/errors/UnsupportedMediaTypeHttpError';
|
||||
|
||||
/**
|
||||
* Parses the incoming {@link HttpRequest} if there is no body or if it contains turtle (or similar) RDF data.
|
||||
* Naively parses the content-type header to determine the body type.
|
||||
*/
|
||||
export class SimpleBodyParser extends BodyParser {
|
||||
private static readonly contentTypes = [
|
||||
'application/n-quads',
|
||||
|
||||
@@ -3,6 +3,10 @@ import { PreferenceParser } from './PreferenceParser';
|
||||
import { RepresentationPreference } from '../representation/RepresentationPreference';
|
||||
import { RepresentationPreferences } from '../representation/RepresentationPreferences';
|
||||
|
||||
/**
|
||||
* Extracts preferences from the accept-* headers from an incoming {@link HttpRequest}.
|
||||
* Parsing of header strings is done naively.
|
||||
*/
|
||||
export class SimplePreferenceParser extends PreferenceParser {
|
||||
public constructor() {
|
||||
super();
|
||||
|
||||
@@ -14,6 +14,10 @@ export interface SimpleRequestParserArgs {
|
||||
bodyParser: BodyParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link Operation} from an incoming {@link HttpRequest} by aggregating the results
|
||||
* of a {@link TargetExtractor}, {@link PreferenceParser}, and {@link BodyParser}.
|
||||
*/
|
||||
export class SimpleRequestParser extends RequestParser {
|
||||
private readonly targetExtractor: TargetExtractor;
|
||||
private readonly preferenceParser: PreferenceParser;
|
||||
|
||||
@@ -4,6 +4,9 @@ import { ResponseDescription } from '../operations/ResponseDescription';
|
||||
import { ResponseWriter } from './ResponseWriter';
|
||||
import { UnsupportedHttpError } from '../../util/errors/UnsupportedHttpError';
|
||||
|
||||
/**
|
||||
* Writes to an {@link HttpResponse} based on the incoming {@link ResponseDescription} or error.
|
||||
*/
|
||||
export class SimpleResponseWriter extends ResponseWriter {
|
||||
public async canHandle(input: { response: HttpResponse; description?: ResponseDescription; error?: Error }): Promise<void> {
|
||||
if (!input.description && !input.error) {
|
||||
|
||||
@@ -2,6 +2,10 @@ import { HttpRequest } from '../../server/HttpRequest';
|
||||
import { ResourceIdentifier } from '../representation/ResourceIdentifier';
|
||||
import { TargetExtractor } from './TargetExtractor';
|
||||
|
||||
/**
|
||||
* Extracts an identifier from an incoming {@link HttpRequest}.
|
||||
* Simply takes the input URl without any parsing/cleaning.
|
||||
*/
|
||||
export class SimpleTargetExtractor extends TargetExtractor {
|
||||
public async canHandle(input: HttpRequest): Promise<void> {
|
||||
if (!input.url) {
|
||||
|
||||
@@ -2,4 +2,7 @@ import { AsyncHandler } from '../../util/AsyncHandler';
|
||||
import { HttpRequest } from '../../server/HttpRequest';
|
||||
import { ResourceIdentifier } from '../representation/ResourceIdentifier';
|
||||
|
||||
/**
|
||||
* Extracts a {@link ResourceIdentifier} from an incoming {@link HttpRequest}.
|
||||
*/
|
||||
export abstract class TargetExtractor extends AsyncHandler<HttpRequest, ResourceIdentifier> {}
|
||||
|
||||
Reference in New Issue
Block a user