From 3cf112bb6b9d85b9b931f8ff575b5ba3b10ed747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20D=C3=BC=C3=BCna?= Date: Thu, 16 Jul 2015 12:14:45 +0300 Subject: [PATCH 1/2] Easy-x-headers --- easy-x-headers/easy-x-headers-tests.ts | 16 ++++++++++++++++ easy-x-headers/easy-x-headers.d.ts | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 easy-x-headers/easy-x-headers-tests.ts create mode 100644 easy-x-headers/easy-x-headers.d.ts diff --git a/easy-x-headers/easy-x-headers-tests.ts b/easy-x-headers/easy-x-headers-tests.ts new file mode 100644 index 000000000..9a306ea6a --- /dev/null +++ b/easy-x-headers/easy-x-headers-tests.ts @@ -0,0 +1,16 @@ +/** + * Created by karl on 14/07/15. + */ + +/// +/// + +import express = require('express'); +import xHeaders = require('easy-x-headers'); + +var app = express(); +app.use(xHeaders.getMiddleware()); + +app.get('/', function (req, res) { + res.json(req.info); +}); diff --git a/easy-x-headers/easy-x-headers.d.ts b/easy-x-headers/easy-x-headers.d.ts new file mode 100644 index 000000000..c0a13d1a8 --- /dev/null +++ b/easy-x-headers/easy-x-headers.d.ts @@ -0,0 +1,18 @@ +// Type definitions for easy-x-headers +// Project: https://github.com/DeadAlready/easy-x-headers +// Definitions by: Karl Düüna +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Express { + export interface Request { + info: any; + } +} + +declare module "easy-x-headers" { + import express = require('express'); + + export function getMiddleware(): express.RequestHandler; +} From abb3f318b878ba5277212e75284ccc3412d871bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20D=C3=BC=C3=BCna?= Date: Thu, 16 Jul 2015 13:07:49 +0300 Subject: [PATCH 2/2] easy-xapi-supertest --- .../easy-xapi-supertest-tests.ts | 27 +++++++++++++++++ easy-xapi-supertest/easy-xapi-supertest.d.ts | 29 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 easy-xapi-supertest/easy-xapi-supertest-tests.ts create mode 100644 easy-xapi-supertest/easy-xapi-supertest.d.ts diff --git a/easy-xapi-supertest/easy-xapi-supertest-tests.ts b/easy-xapi-supertest/easy-xapi-supertest-tests.ts new file mode 100644 index 000000000..5b43ce061 --- /dev/null +++ b/easy-xapi-supertest/easy-xapi-supertest-tests.ts @@ -0,0 +1,27 @@ +/** + * Created by karl on 14/07/15. + */ + +/// +/// + +import express = require('express'); +import eSupertest = require('easy-xapi-supertest'); + +var app = express(); + +var getAgent = eSupertest.getAgentFactory(app); + +var agent = getAgent({ + user: 'Jack', + role: 'user' +}); + +var getAgent2 = eSupertest.getAgentFactory(app, function (user:string, role?:string) { + return { + user: user, + role: role || 'user' + } +}); + +var agent = getAgent2('Jack'); diff --git a/easy-xapi-supertest/easy-xapi-supertest.d.ts b/easy-xapi-supertest/easy-xapi-supertest.d.ts new file mode 100644 index 000000000..4ea936976 --- /dev/null +++ b/easy-xapi-supertest/easy-xapi-supertest.d.ts @@ -0,0 +1,29 @@ +// Type definitions for easy-x-headers +// Project: https://github.com/DeadAlready/easy-x-headers +// Definitions by: Karl Düüna +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "easy-xapi-supertest" { + import express = require('express'); + + export interface BodyAgent { + send(data: Object): any; + attach(arg1: any, arg2?: any): any; + } + + export interface Agent { + get(url:string): any; + delete(url:string): any; + post(url:string): BodyAgent; + patch(url:string): BodyAgent; + put(url:string): BodyAgent; + } + + interface getAgent { + (...args:any[]): Agent + } + + export function getAgentFactory(app: express.Application, transform?: Function): getAgent; +}