From 204569719e06f6cc5b9cf3780d06f7fd919ade06 Mon Sep 17 00:00:00 2001 From: Bret Little Date: Tue, 12 Feb 2013 22:08:16 -0700 Subject: [PATCH] Add restify definition --- restify/restify-test.ts | 17 +++++++++++++++++ restify/restify.d.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 restify/restify-test.ts create mode 100644 restify/restify.d.ts diff --git a/restify/restify-test.ts b/restify/restify-test.ts new file mode 100644 index 000000000..57510df97 --- /dev/null +++ b/restify/restify-test.ts @@ -0,0 +1,17 @@ +/// + +import restify = module("restify"); + +var server = restify.createServer({ + formatters: { + 'application/foo': function formatFoo(req, res, body) { + if (body instanceof Error) + return body.stack; + + if (body) + return body.toString('base64'); + + return body; + } + } +}); diff --git a/restify/restify.d.ts b/restify/restify.d.ts new file mode 100644 index 000000000..ae4b7429b --- /dev/null +++ b/restify/restify.d.ts @@ -0,0 +1,40 @@ +interface Server { + use: (... handler: any[]) => any; + post: (route: any, routeCallBack: (req: any, res: any, next: any) => any) => any; + put: (route: any, routeCallBack: (req: any, res: any, next: any) => any) => any; + del: (route: any, routeCallBack: (req: any, res: any, next: any) => any) => any; + get: (route: any, routeCallBack: (req: any, res: any, next: any) => any) => any; + head: (route: any, routeCallBack: (req: any, res: any, next: any) => any) => any; +} + +interface ServerOptions { + certificate ?: string; + key ?: string; + formatters ?: Object; + log ?: Object; + name ?: string; + spdy ?: Object; + version ?: string; + responseTimerHeader ?: string; + responseTimeFormatter ?: (durationInMilliseconds: number) => any; +} + +declare module "restify" { + export function createServer(options: ServerOptions): Server; + export class ConflictError { new(message: any): ConflictError; }; + export class InvalidArguementError { new(message: any): InvalidArguementError; }; + export class RestError { new(message: any): RestError; }; + export class BadDigestError { new(message: any): BadDigestError; }; + export class BadMethodError { new(message: any): BadMethodError; }; + export class InternalError { new(message: any): InternalError; }; + export class InvalidContentError { new(message: any): InvalidContentError; }; + export class InvalidCredentialsError { new(message: any): InvalidCredentialsError; }; + export class InvalidHeaderError { new(message: any): InvalidHeaderError; }; + export class InvalidVersionError { new(message: any): InvalidVersionError; }; + export class MissingParameterError { new(message: any): MissingParameterError; }; + export class NotAuthorizedError { new(message: any): NotAuthorizedError; }; + export class RequestExpiredError { new(message: any): RequestExpiredError; }; + export class RequestThrottledError { new(message: any): RequestThrottledError; }; + export class ResourceNotFoundError { new(message: any): ResourceNotFoundError; }; + export class WrongAcceptError { new(message: any): WrongAcceptError; }; +}