diff --git a/easy-xapi/easy-xapi-tests.ts b/easy-xapi/easy-xapi-tests.ts new file mode 100644 index 0000000000..70c5351d4c --- /dev/null +++ b/easy-xapi/easy-xapi-tests.ts @@ -0,0 +1,32 @@ +/** + * Created by karl on 14/07/15. + */ + +/// +/// + +import express = require('express'); +import eXapi = require('easy-xapi'); + +eXapi.init({ + jSend: { + partial: true + } +}); + +var xApi = eXapi.create({ + root: __dirname, + log: { + name: 'Log', + level: 'info' + }, + port: 3000, + name: 'test', + mount: function (app) { + app.get('/', function (req, res) { + res.send('ok'); + }); + } +}); + +xApi.listen(); diff --git a/easy-xapi/easy-xapi.d.ts b/easy-xapi/easy-xapi.d.ts new file mode 100644 index 0000000000..612dd51d56 --- /dev/null +++ b/easy-xapi/easy-xapi.d.ts @@ -0,0 +1,44 @@ +// Type definitions for easy-xapi +// Project: https://github.com/DeadAlready/easy-xapi +// Definitions by: Karl Düüna +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module Express { + export interface Request { + log: any; + info: any; + } +} + +declare module "easy-xapi" { + import express = require('express'); + import http = require('http'); + + interface InitConfig { + jSend?: {partial: boolean}; + } + + interface Config { + root: string; + port: number; + name: string; + log: { + name: string; + level: string + } + mount: (app: express.Application) => void + } + + interface Result { + express: any; + app: express.Application; + server: http.Server; + listen: () => void; + } + + export function init(conf: InitConfig): void; + export function create(conf: Config): Result; +}