Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change request.body and ctx.config type #2145

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ export interface Logger {
error(info: string | Error, ...args: any[]): void;
}

export type RequestArrayBody = any[];
export type RequestObjectBody = { [key: string]: any };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这 2 个干掉的话会不会 break ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个没必要用了吧,只有 request.body 可能用上

interface Request extends KoaApplication.Request { // tslint:disable-line
/**
* detect if response should be json
Expand Down Expand Up @@ -159,6 +157,8 @@ interface ContextView { // tslint:disable-line
export type LoggerLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';

export interface EggAppConfig {
[key: string]: any;

workerStartTimeout: number;
baseDir: string;
/**
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/apps/app-ts/app/controller/foo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, RequestObjectBody } from 'egg';
import { Controller } from 'egg';

// add user controller and service
declare module 'egg' {
Expand All @@ -13,7 +13,7 @@ export default class FooController extends Controller {
try {
this.ctx.body = await this.ctx.service.foo.bar();
} catch (e) {
const body: RequestObjectBody = this.ctx.request.body;
const body = this.ctx.request.body;
this.app.logger.info(e.name, body.foo);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apps/app-ts/app/service/foo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ declare module 'egg' {

export default class FooService extends Service {
async bar() {
return { env: this.config.env };
return { env: this.config.env, bar: this.config.bar };
}
}