fix: add documentation for many classes where it was missing

This commit is contained in:
Joachim Van Herwegen
2020-06-24 16:27:38 +02:00
parent 39853b0bd0
commit fe11f4b1ce
18 changed files with 62 additions and 2 deletions

View File

@@ -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> {}

View File

@@ -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> {}

View File

@@ -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',

View File

@@ -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();

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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> {}