typescript-rest
Version:
A Library to create RESTFul APIs with Typescript
78 lines (77 loc) • 1.88 kB
TypeScript
import { HttpMethod } from './server-types';
export interface SeviceProperty {
type: ParamType;
name: string;
propertyType: any;
}
/**
* Metadata for REST service classes
*/
export declare class ServiceClass {
constructor(targetClass: any);
targetClass: any;
path: string;
methods: Map<string, ServiceMethod>;
languages: Array<string>;
accepts: Array<string>;
properties: Map<string, SeviceProperty>;
addProperty(key: string, paramType: ParamType, paramName: string, propertyType: any): void;
hasProperties(): boolean;
}
/**
* Metadata for REST service methods
*/
export declare class ServiceMethod {
name: string;
path: string;
resolvedPath: string;
httpMethod: HttpMethod;
parameters: Array<MethodParam>;
mustParseCookies: boolean;
files: Array<FileParam>;
mustParseBody: boolean;
bodyParserOptions: any;
mustParseForms: boolean;
acceptMultiTypedParam: boolean;
languages: Array<string>;
accepts: Array<string>;
resolvedLanguages: Array<string>;
resolvedAccepts: Array<string>;
}
/**
* Metadata for File parameters on REST methods
*/
export declare class FileParam {
constructor(name: string, singleFile: boolean);
name: string;
singleFile: boolean;
}
/**
* Metadata for REST service method parameters
*/
export declare class MethodParam {
constructor(name: string, type: Function, paramType: ParamType);
name: string;
type: Function;
paramType: ParamType;
}
/**
* Enumeration of accepted parameter types
*/
export declare enum ParamType {
path = 0,
query = 1,
header = 2,
cookie = 3,
form = 4,
body = 5,
param = 6,
file = 7,
files = 8,
context = 9,
context_request = 10,
context_response = 11,
context_next = 12,
context_accept = 13,
context_accept_language = 14,
}