Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 21x 21x 21x 21x 1x 1x 4x 1x | 'use strict';
import * as express from 'express';
/**
* Limits for file uploads
*/
export interface FileLimits {
/** Max field name size (Default: 100 bytes) */
fieldNameSize?: number;
/** Max field value size (Default: 1MB) */
fieldSize?: number;
/** Max number of non- file fields (Default: Infinity) */
fields?: number;
/** For multipart forms, the max file size (in bytes)(Default: Infinity) */
fileSize?: number;
/** For multipart forms, the max number of file fields (Default: Infinity) */
files?: number;
/** For multipart forms, the max number of parts (fields + files)(Default: Infinity) */
parts?: number;
/** For multipart forms, the max number of header key=> value pairs to parse Default: 2000(same as node's http). */
headerPairs?: number;
}
/**
* The supported HTTP methods.
*/
export enum HttpMethod {
GET = 1,
POST,
PUT,
DELETE,
HEAD,
OPTIONS,
PATCH
}
/**
* Represents the current context of the request being handled.
*/
export class ServiceContext {
/**
* The resolved language to be used in the current request handling.
*/
public language: string;
/**
* The preferred media type to be used in the current request handling.
*/
public accept: string;
/**
* The request object.
*/
public request: express.Request;
/**
* The response object
*/
public response: express.Response;
/**
* The next function. It can be used to delegate to the next middleware
* registered the processing of the current request.
*/
public next: express.NextFunction;
}
/**
* The Base class for all HTTP errors
*/
export abstract class HttpError extends Error {
constructor(name: string,
public statusCode: number,
public message: string) {
super(message);
this.name = name;
}
}
/**
* Used to create a reference to a resource.
*/
export abstract class ReferencedResource<T> {
/**
* Constructor. Receives the location of the resource.
* @param location To be added to the Location header on response
* @param statusCode the response status code to be sent
* @param body the body to be sent
*/
constructor(public location: string, public statusCode: number, public body?: T) { }
}
/**
* The factory used to instantiate the object services
*/
export interface ServiceFactory {
/**
* Create a new service object. Called before each request handling.
*/
create: (serviceClass: Function, context: ServiceContext) => any;
/**
* Return the type used to handle requests to the target service.
* By default, returns the serviceClass received, but you can use this
* to implement IoC integrations.
*/
getTargetClass: (serviceClass: Function) => FunctionConstructor;
}
/**
* An optional authenticator for rest services
*/
export interface ServiceAuthenticator {
/**
* Get the user list of roles.
*/
getRoles: (req: express.Request) => Array<string>;
/**
* Initialize the authenticator
*/
initialize(router: express.Router): void;
/**
* Retrieve the middleware used to authenticate users.
*/
getMiddleware(): express.RequestHandler;
}
export type ServicePreProcessor = (req: express.Request) => void;
|