Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a17a49b

Browse files
committed
refactor(session): improved session drivers handling and exposing session manager
Session manager has been exposed via IOC container to be extended and session drivers are now handled in better way
1 parent 30cfe41 commit a17a49b

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

providers/SessionProvider.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ const ServiceProvider = require('adonis-fold').ServiceProvider
1111
class SessionProvider extends ServiceProvider {
1212

1313
* register () {
14+
const Session = require('../src/Session')
1415
this.app.singleton('Adonis/Src/Session', function (app) {
1516
const Config = app.use('Adonis/Src/Config')
16-
const Session = require('../src/Session')
1717
return new Session(Config)
1818
})
19+
20+
this.app.manager('Adonis/Src/Session', Session)
1921
}
2022
}
2123

src/Session/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ const SessionManager = require('./SessionManager')
1616
*/
1717
class Session {
1818

19-
static drivers () {
20-
return {}
21-
}
22-
2319
/**
2420
* @description extend method for ioc to extend
2521
* session provider
@@ -30,6 +26,7 @@ class Session {
3026
* @public
3127
*/
3228
static extend (key, value) {
29+
this.drivers = this.drivers || {}
3330
this.drivers[key] = value
3431
}
3532

test/unit/sessions.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ describe('Session', function () {
4444
expect(session.driver instanceof Redis).to.equal(true)
4545
})
4646

47-
it('should return list of extended session drivers', function * () {
48-
expect(Session.drivers()).to.be.an('object')
49-
})
50-
5147
it('should make an instance of pre existing drivers using make method', function * () {
5248
let Config = {}
5349
Config.get = function () {

0 commit comments

Comments
 (0)