-
-
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.
- Loading branch information
Showing
13 changed files
with
171 additions
and
7 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
Empty file.
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
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,14 @@ | ||
'use strict'; | ||
|
||
class DockerAdapter { | ||
constructor(app) { | ||
this.app = app; | ||
} | ||
|
||
async inspectDocker() { | ||
return 'docker'; | ||
} | ||
|
||
} | ||
|
||
module.exports = DockerAdapter; |
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'; | ||
|
||
class UserController { | ||
constructor(ctx) { | ||
this.ctx = ctx; | ||
this.app = ctx.app; | ||
} | ||
|
||
async get() { | ||
this.ctx.body = { | ||
adapter: await this.app.adapter.docker.inspectDocker(), | ||
repository: await this.ctx.repository.user.get(), | ||
}; | ||
} | ||
} | ||
|
||
module.exports = UserController; |
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,14 @@ | ||
'use strict'; | ||
|
||
class UserRepository { | ||
constructor(ctx) { | ||
this.ctx = ctx; | ||
} | ||
|
||
async get() { | ||
return this.ctx.params.name; | ||
} | ||
|
||
} | ||
|
||
module.exports = UserRepository; |
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 @@ | ||
'use strict'; | ||
|
||
module.exports = app => { | ||
app.router.get('/users/:name', app.controller.user.get); | ||
}; |
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,15 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
keys: '123', | ||
customLoader: { | ||
adapter: { | ||
directory: 'app/adapter', | ||
inject: 'app', | ||
}, | ||
repository: { | ||
directory: 'app/repository', | ||
inject: 'ctx', | ||
}, | ||
}, | ||
}; |
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,3 @@ | ||
{ | ||
"name": "custom-loader" | ||
} |
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,26 @@ | ||
'use strict'; | ||
|
||
const mock = require('egg-mock'); | ||
const utils = require('../../utils'); | ||
|
||
describe('test/lib/core/custom_loader.test.js', () => { | ||
afterEach(mock.restore); | ||
|
||
let app; | ||
before(() => { | ||
app = utils.app('apps/custom-loader'); | ||
return app.ready(); | ||
}); | ||
after(() => app.close()); | ||
|
||
it('should', async () => { | ||
await app.httpRequest() | ||
.get('/users/popomore') | ||
.expect({ | ||
adapter: 'docker', | ||
repository: 'popomore', | ||
}) | ||
.expect(200); | ||
}); | ||
|
||
}); |
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