From fad8178fc8d690d5f9ac46d41ba7a606e89d0cc7 Mon Sep 17 00:00:00 2001 From: Viktor Isaev Date: Thu, 12 Oct 2017 01:45:34 +0300 Subject: [PATCH] Added typings for "restify-cookies". (#20489) * Added typings for "require-dir". * Fixed dtslint errors. * Fixed By field. * Added typings for "restify-cookies". --- types/restify-cookies/index.d.ts | 22 ++++++++++++++++++ .../restify-cookies/restify-cookies-tests.ts | 8 +++++++ types/restify-cookies/tsconfig.json | 23 +++++++++++++++++++ types/restify-cookies/tslint.json | 1 + 4 files changed, 54 insertions(+) create mode 100644 types/restify-cookies/index.d.ts create mode 100644 types/restify-cookies/restify-cookies-tests.ts create mode 100644 types/restify-cookies/tsconfig.json create mode 100644 types/restify-cookies/tslint.json diff --git a/types/restify-cookies/index.d.ts b/types/restify-cookies/index.d.ts new file mode 100644 index 0000000000..842e6c425e --- /dev/null +++ b/types/restify-cookies/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for restify-cookies 0.2 +// Project: https://github.com/nathschmidt/restify-cookies +// Definitions by: weekens +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as restify from 'restify'; + +declare module 'restify' { + interface CookieOptions { + encode?: (input: string) => string; // tslint:disable-line:prefer-method-signature + maxAge?: number; + domain?: string; + path?: string; + expires?: string; + httpOnly?: boolean; + secure?: boolean; + } + + interface Response { + setCookie(key: string, val: string, options?: CookieOptions): void; + } +} diff --git a/types/restify-cookies/restify-cookies-tests.ts b/types/restify-cookies/restify-cookies-tests.ts new file mode 100644 index 0000000000..e6a68e5689 --- /dev/null +++ b/types/restify-cookies/restify-cookies-tests.ts @@ -0,0 +1,8 @@ +import { Request, Response, Server } from 'restify'; +import 'restify-cookies'; + +function test(server: Server) { + server.get('/api/test', (req: Request, res: Response) => { + res.setCookie('myCookie', 'test', { path: '/' }); + }); +} diff --git a/types/restify-cookies/tsconfig.json b/types/restify-cookies/tsconfig.json new file mode 100644 index 0000000000..b86ecbf07e --- /dev/null +++ b/types/restify-cookies/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "restify-cookies-tests.ts" + ] +} diff --git a/types/restify-cookies/tslint.json b/types/restify-cookies/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/restify-cookies/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }