-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add missing framework support for single process mode (#3445)
- Loading branch information
1 parent
f73790d
commit 277c024
Showing
15 changed files
with
221 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
module.exports = app => { | ||
app.ready(() => { | ||
app.config.tips = 'hello egg started'; | ||
// dynamic router | ||
app.all('/all', app.controller.home); | ||
}); | ||
}; |
9 changes: 9 additions & 0 deletions
9
test/fixtures/apps/custom-framework-demo/app/controller/foo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
module.exports = app => { | ||
return class Foo extends app.Controller { | ||
* bar() { | ||
this.ctx.body = 'this is bar!'; | ||
} | ||
}; | ||
}; |
6 changes: 6 additions & 0 deletions
6
test/fixtures/apps/custom-framework-demo/app/controller/hello.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
module.exports = function*() { | ||
this.cookies.set('hi', 'foo'); | ||
this.body = 'hello'; | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/fixtures/apps/custom-framework-demo/app/controller/home.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = function* () { | ||
this.body = { | ||
workerTitle: process.title | ||
}; | ||
}; |
10 changes: 10 additions & 0 deletions
10
test/fixtures/apps/custom-framework-demo/app/controller/ip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports = function* () { | ||
if (this.query.set_ip) { | ||
this.ip = this.query.set_ip; | ||
} | ||
this.body = { | ||
ip: this.ip, | ||
}; | ||
}; |
17 changes: 17 additions & 0 deletions
17
test/fixtures/apps/custom-framework-demo/app/controller/logger.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
module.exports = function*() { | ||
const message = this.query.message; | ||
|
||
this.logger.debug('debug %s', message); | ||
this.logger.info('info %s', message); | ||
this.logger.warn('warn %s', message); | ||
this.logger.error(new Error('error ' + message)); | ||
|
||
this.coreLogger.debug('core debug %s', message); | ||
this.coreLogger.info('core info %s', message); | ||
this.coreLogger.warn('core warn %s', message); | ||
this.coreLogger.error(new Error('core error ' + message)); | ||
|
||
this.body = 'logger'; | ||
}; |
19 changes: 19 additions & 0 deletions
19
test/fixtures/apps/custom-framework-demo/app/controller/obj.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
module.exports = app => { | ||
return { | ||
* bar() { | ||
this.ctx.body = 'this is obj bar!'; | ||
}, | ||
|
||
* error() { | ||
aaa; | ||
}, | ||
|
||
subObj: { | ||
* hello() { | ||
this.ctx.body = 'this is subObj hello!'; | ||
}, | ||
}, | ||
}; | ||
}; |
19 changes: 19 additions & 0 deletions
19
test/fixtures/apps/custom-framework-demo/app/controller/obj2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
* bar() { | ||
this.ctx.body = 'this is obj bar!'; | ||
}, | ||
|
||
subObj: { | ||
* hello() { | ||
this.ctx.body = 'this is subObj hello!'; | ||
}, | ||
|
||
subSubObj: { | ||
* hello() { | ||
this.ctx.body = 'this is subSubObj hello!'; | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = app => { | ||
app.get('home', '/', 'home'); | ||
app.get('/hello', app.controller.hello); | ||
app.get('/logger', app.controller.logger); | ||
app.get('/protocol', function*() { | ||
this.body = this.protocol; | ||
}); | ||
|
||
app.get('/user.json', app.jsonp(), function*() { | ||
this.body = { name: 'fengmk2' }; | ||
}); | ||
app.get('/ip', app.controller.ip); | ||
|
||
app.get('/class-controller', 'foo.bar'); | ||
|
||
app.get('/obj-controller', 'obj.bar'); | ||
app.get('/obj-error', 'obj.error'); | ||
app.get('/subobj-controller', 'obj.subObj.hello'); | ||
|
||
app.get('/obj2-controller', app.controller.obj2.bar); | ||
app.get('/subobj2-controller', app.controller.obj2.subObj.hello); | ||
app.get('/subSubObj-hello', app.controller.obj2.subObj.subSubObj.hello); | ||
}; |
22 changes: 22 additions & 0 deletions
22
test/fixtures/apps/custom-framework-demo/config/config.default.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
exports.keys = 'foo'; | ||
exports.proxy = true; | ||
exports.buffer = Buffer.from('test'); | ||
|
||
exports.pass = 'this is pass'; | ||
exports.pwd = 'this is pwd'; | ||
exports.password = 'this is password'; | ||
exports.passwordNew = 'this is passwordNew'; | ||
exports.mysql = { | ||
passd: 'this is passd', | ||
passwd: 'this is passwd', | ||
secret: 'secret 123', | ||
secretNumber: 123, | ||
secretBoolean: true, | ||
masterKey: 'this is masterKey', | ||
accessKey: 'this is accessKey', | ||
accessId: 'this is accessId', | ||
consumerSecret: 'this is consumerSecret', | ||
someSecret: null, | ||
}; | ||
|
||
exports.tips = 'hello egg'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const egg = require('../../../../'); | ||
|
||
egg.start().then(app => { | ||
app.listen(3000); | ||
console.log('listen 3000'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "custom-framework-demo", | ||
"egg": { | ||
"framework": "../test/fixtures/custom-egg" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
'use strict'; | ||
|
||
module.exports = require('../../../index'); | ||
module.exports.Application = class Application extends module.exports.Application { | ||
constructor(...args) { | ||
super(...args); | ||
this.customEgg = true; | ||
} | ||
|
||
get [Symbol.for('egg#eggPath')]() { | ||
return __dirname; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters