Skip to content

Commit

Permalink
feat(d.ts): add createAnonymousContext & runInBackground (#2501)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngot authored and atian25 committed May 5, 2018
1 parent c013ef3 commit 20356bf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,22 @@ declare module 'egg' {
Controller: Controller;

middleware: KoaApplication.Middleware[] & IMiddleware;

/**
* Create an anonymous context, the context isn't request level, so the request is mocked.
* then you can use context level API like `ctx.service`
* @member {String} Application#createAnonymousContext
* @param {Request} req - if you want to mock request like querystring, you can pass an object to this function.
* @return {Context} context
*/
createAnonymousContext(req?: Request): Context;

/**
* Run async function in the background
* @see Context#runInBackground
* @param {Function} scope - the first args is an anonymous ctx
*/
runInBackground(scope: (ctx: Context) => void): void;
}

export interface FileStream extends Readable { // tslint:disable-line
Expand Down

0 comments on commit 20356bf

Please sign in to comment.