Skip to content

Commit

Permalink
feat: [BREAKING_CHANGE] remove poweredBy && config.core (eggjs#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored and popomore committed Aug 29, 2016
1 parent c356b04 commit 7a17c0f
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 44 deletions.
10 changes: 0 additions & 10 deletions app/extend/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ module.exports = {
return context;
},

/**
* X-Powered-By Header
* @member {String} Application#poweredBy
* @private
* @since 1.0.0
*/
get poweredBy() {
return this.config.core.name;
},

/**
* Service 基类
* @member {Service} Application#Service
Expand Down
7 changes: 1 addition & 6 deletions app/middleware/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@

'use strict';

module.exports = (_, app) => {
const poweredBy = typeof app.poweredBy === 'string' ? app.poweredBy : null;

module.exports = () => {
return function* meta(next) {
if (poweredBy) this.setRawHeader('X-Powered-By', poweredBy);

yield next;

// total response time header
this.setRawHeader('X-Readtime', Date.now() - this.starttime);
};
Expand Down
9 changes: 0 additions & 9 deletions config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ module.exports = appInfo => {
rundir: path.join(appInfo.baseDir, 'run'),
};

/**
* Framework name
* @member {Object} Config#core
* @property {String} name - 'Egg' by default
*/
exports.core = {
name: 'Egg',
};

/**
* notfound 中间件 options
*
Expand Down
2 changes: 0 additions & 2 deletions lib/egg.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class EggApplication extends EggCore {
* name: 'mockapp',
* env: 'test',
* subdomainOffset: 2,
* poweredBy: 'egg/1.0.0',
* config: '<egg config>',
* controller: '<egg controller>',
* service: '<egg service>',
Expand Down Expand Up @@ -90,7 +89,6 @@ class EggApplication extends EggCore {
'baseDir',
'env',
'subdomainOffset',
'poweredBy',
]);

abbr(res, this, [
Expand Down
2 changes: 1 addition & 1 deletion test/lib/core/app/extend/application.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('test/lib/core/app/extend/application.test.js', () => {
app.ready(() => {
app.inspect().should.have.properties([
'name', 'baseDir',
'env', 'subdomainOffset', 'poweredBy',
'env', 'subdomainOffset',
'controller', 'middlewares', 'serviceClasses',
'config', 'urllib', 'loggers',
]);
Expand Down
14 changes: 0 additions & 14 deletions test/lib/core/app/middleware/meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ describe('test/lib/core/app/middleware/meta.test.js', () => {

afterEach(mm.restore);

it('should get X-Powered-By header', () => {
return request(app.callback())
.get('/')
.expect('X-Powered-By', 'Egg')
.expect(200);
});

it('should still get X-Powered-By header when controller error', () => {
return request(app.callback())
.get('/error')
.expect('X-Powered-By', 'Egg')
.expect(500);
});

it('should get X-Readtime header', () => {
return request(app.callback())
.get('/')
Expand Down
4 changes: 2 additions & 2 deletions test/lib/core/config/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('test/lib/core/config/config.test.js', () => {

afterEach(mm.restore);

it('should return config.core.name that is deprecated', () => {
app.config.core.name.should.equal('Egg');
it('should return config.name', () => {
app.config.name.should.equal('demo');
});
});

0 comments on commit 7a17c0f

Please sign in to comment.