refactor: Move handlers into subfolder.

This commit is contained in:
Ruben Verborgh 2021-01-26 22:36:58 +01:00 committed by Joachim Van Herwegen
parent d7256fb20a
commit eb1440851a
29 changed files with 43 additions and 41 deletions

View File

@ -1,5 +1,5 @@
import type { HttpRequest } from '../server/HttpRequest';
import { AsyncHandler } from '../util/AsyncHandler';
import { AsyncHandler } from '../util/handlers/AsyncHandler';
import type { Credentials } from './Credentials';
/**

View File

@ -1,7 +1,7 @@
import type { Credentials } from '../authentication/Credentials';
import type { PermissionSet } from '../ldp/permissions/PermissionSet';
import type { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
import { AsyncHandler } from '../util/AsyncHandler';
import { AsyncHandler } from '../util/handlers/AsyncHandler';
/**
* Verifies if the given credentials have access to the given permissions on the given resource.

View File

@ -187,6 +187,12 @@ export * from './util/errors/SystemError';
export * from './util/errors/UnauthorizedHttpError';
export * from './util/errors/UnsupportedMediaTypeHttpError';
// Util/Handlers
export * from './util/handlers/AsyncHandler';
export * from './util/handlers/SequenceHandler';
export * from './util/handlers/UnsupportedAsyncHandler';
export * from './util/handlers/WaterfallHandler';
// Util/Identifiers
export * from './util/identifiers/IdentifierStrategy';
export * from './util/identifiers/SingleRootIdentifierStrategy';
@ -198,16 +204,12 @@ export * from './util/locking/SingleThreadedResourceLocker';
export * from './util/locking/WrappedExpiringResourceLocker';
// Util
export * from './util/AsyncHandler';
export * from './util/ContentTypes';
export * from './util/GuardedStream';
export * from './util/HeaderUtil';
export * from './util/PathUtil';
export * from './util/QuadUtil';
export * from './util/RecordObject';
export * from './util/SequenceHandler';
export * from './util/StreamUtil';
export * from './util/TermUtil';
export * from './util/UnsupportedAsyncHandler';
export * from './util/Vocabularies';
export * from './util/WaterfallHandler';

View File

@ -1,3 +1,3 @@
import { AsyncHandler } from '../util/AsyncHandler';
import { AsyncHandler } from '../util/handlers/AsyncHandler';
export abstract class Initializer extends AsyncHandler {}

View File

@ -1,5 +1,5 @@
import type { HttpRequest } from '../../server/HttpRequest';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { Representation } from '../representation/Representation';
import type { RepresentationMetadata } from '../representation/RepresentationMetadata';

View File

@ -1,5 +1,5 @@
import type { HttpRequest } from '../../server/HttpRequest';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { RepresentationPreferences } from '../representation/RepresentationPreferences';
/**

View File

@ -1,5 +1,5 @@
import type { HttpRequest } from '../../server/HttpRequest';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { Operation } from '../operations/Operation';
/**

View File

@ -1,5 +1,5 @@
import type { HttpResponse } from '../../server/HttpResponse';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { ResponseDescription } from './response/ResponseDescription';
/**

View File

@ -1,5 +1,5 @@
import type { HttpRequest } from '../../server/HttpRequest';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { ResourceIdentifier } from '../representation/ResourceIdentifier';
/**

View File

@ -1,5 +1,5 @@
import type { HttpRequest } from '../../../server/HttpRequest';
import { AsyncHandler } from '../../../util/AsyncHandler';
import { AsyncHandler } from '../../../util/handlers/AsyncHandler';
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../representation/ResourceIdentifier';

View File

@ -1,5 +1,5 @@
import type { HttpResponse } from '../../../server/HttpResponse';
import { AsyncHandler } from '../../../util/AsyncHandler';
import { AsyncHandler } from '../../../util/handlers/AsyncHandler';
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata';
/**

View File

@ -1,4 +1,4 @@
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { ResponseDescription } from '../http/response/ResponseDescription';
import type { Operation } from './Operation';

View File

@ -1,4 +1,4 @@
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { Operation } from '../operations/Operation';
import type { PermissionSet } from './PermissionSet';

View File

@ -1,5 +1,5 @@
import type { Representation } from '../../ldp/representation/Representation';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { Agent } from './Agent';
/**

View File

@ -1,4 +1,4 @@
import { AsyncHandler } from '../util/AsyncHandler';
import { AsyncHandler } from '../util/handlers/AsyncHandler';
import type { HttpRequest } from './HttpRequest';
import type { HttpResponse } from './HttpResponse';

View File

@ -1,5 +1,5 @@
import type WebSocket from 'ws';
import { AsyncHandler } from '../util/AsyncHandler';
import { AsyncHandler } from '../util/handlers/AsyncHandler';
import type { HttpRequest } from './HttpRequest';
/**

View File

@ -1,7 +1,7 @@
import type { Representation } from '../../ldp/representation/Representation';
import { getLoggerFor } from '../../logging/LogUtil';
import { InternalServerError } from '../../util/errors/InternalServerError';
import { UnsupportedAsyncHandler } from '../../util/UnsupportedAsyncHandler';
import { UnsupportedAsyncHandler } from '../../util/handlers/UnsupportedAsyncHandler';
import { hasMatchingMediaTypes } from './ConversionUtil';
import { RepresentationConverter } from './RepresentationConverter';
import type { RepresentationConverterArgs } from './RepresentationConverter';

View File

@ -1,7 +1,7 @@
import type { Representation } from '../../ldp/representation/Representation';
import type { RepresentationPreferences } from '../../ldp/representation/RepresentationPreferences';
import type { ResourceIdentifier } from '../../ldp/representation/ResourceIdentifier';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
export interface RepresentationConverterArgs {
/**

View File

@ -1,5 +1,5 @@
import type { Patch } from '../../ldp/http/Patch';
import type { ResourceIdentifier } from '../../ldp/representation/ResourceIdentifier';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
export abstract class PatchHandler extends AsyncHandler<{identifier: ResourceIdentifier; patch: Patch}> {}

View File

@ -1,6 +1,6 @@
import type { Representation } from '../../ldp/representation/Representation';
import type { ResourceIdentifier } from '../../ldp/representation/ResourceIdentifier';
import { AsyncHandler } from '../../util/AsyncHandler';
import { AsyncHandler } from '../../util/handlers/AsyncHandler';
import type { ResourceStore } from '../ResourceStore';
/**

View File

@ -1,5 +1,5 @@
import { NotImplementedHttpError } from '../errors/NotImplementedHttpError';
import { AsyncHandler } from './AsyncHandler';
import { NotImplementedHttpError } from './errors/NotImplementedHttpError';
/**
* Handler that does not support any input and will always throw an error.

View File

@ -1,9 +1,9 @@
import { getLoggerFor } from '../logging/LogUtil';
import { getLoggerFor } from '../../logging/LogUtil';
import { BadRequestHttpError } from '../errors/BadRequestHttpError';
import { isNativeError } from '../errors/ErrorUtil';
import { HttpError } from '../errors/HttpError';
import { InternalServerError } from '../errors/InternalServerError';
import type { AsyncHandler } from './AsyncHandler';
import { BadRequestHttpError } from './errors/BadRequestHttpError';
import { isNativeError } from './errors/ErrorUtil';
import { HttpError } from './errors/HttpError';
import { InternalServerError } from './errors/InternalServerError';
/**
* A composite handler that tries multiple handlers one by one

View File

@ -1,5 +1,5 @@
import { AsyncHandler } from '../../../src/util/AsyncHandler';
import { StaticAsyncHandler } from '../../util/StaticAsyncHandler';
import { AsyncHandler } from '../../../../src/util/handlers/AsyncHandler';
import { StaticAsyncHandler } from '../../../util/StaticAsyncHandler';
describe('An AsyncHandler', (): void => {
it('supports any input by default.', async(): Promise<void> => {

View File

@ -1,5 +1,5 @@
import type { AsyncHandler } from '../../../src/util/AsyncHandler';
import { SequenceHandler } from '../../../src/util/SequenceHandler';
import type { AsyncHandler } from '../../../../src/util/handlers/AsyncHandler';
import { SequenceHandler } from '../../../../src/util/handlers/SequenceHandler';
describe('A SequenceHandler', (): void => {
const handlers: jest.Mocked<AsyncHandler<string, string>>[] = [

View File

@ -1,5 +1,5 @@
import { NotImplementedHttpError } from '../../../src/util/errors/NotImplementedHttpError';
import { UnsupportedAsyncHandler } from '../../../src/util/UnsupportedAsyncHandler';
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
import { UnsupportedAsyncHandler } from '../../../../src/util/handlers/UnsupportedAsyncHandler';
describe('An UnsupportedAsyncHandler', (): void => {
it('throws a default error when no message is set.', async(): Promise<void> => {

View File

@ -1,8 +1,8 @@
import type { AsyncHandler } from '../../../src/util/AsyncHandler';
import { BadRequestHttpError } from '../../../src/util/errors/BadRequestHttpError';
import { HttpError } from '../../../src/util/errors/HttpError';
import { WaterfallHandler } from '../../../src/util/WaterfallHandler';
import { StaticAsyncHandler } from '../../util/StaticAsyncHandler';
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
import { HttpError } from '../../../../src/util/errors/HttpError';
import type { AsyncHandler } from '../../../../src/util/handlers/AsyncHandler';
import { WaterfallHandler } from '../../../../src/util/handlers/WaterfallHandler';
import { StaticAsyncHandler } from '../../../util/StaticAsyncHandler';
describe('A WaterfallHandler', (): void => {
describe('with no handlers', (): void => {

View File

@ -1,4 +1,4 @@
import { AsyncHandler } from '../../src/util/AsyncHandler';
import { AsyncHandler } from '../../src/util/handlers/AsyncHandler';
export class StaticAsyncHandler<TOut> extends AsyncHandler<any, TOut> {
private readonly canHandleStatic: boolean;