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; +} 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; +}