Add restify definition

This commit is contained in:
Bret Little
2013-02-12 22:08:16 -07:00
parent 8ebf0010ca
commit 204569719e
2 changed files with 57 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
/// <reference path="restify.d.ts" />
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;
}
}
});
+40
View File
@@ -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; };
}