mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-03 23:36:21 +02:00
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
"use strict";
|
|
/**
|
|
* @adonisjs/session
|
|
*
|
|
* (c) Harminder Virk <virk@adonisjs.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
/**
|
|
* Session provider for AdonisJS
|
|
*/
|
|
class SessionProvider {
|
|
constructor(app) {
|
|
this.app = app;
|
|
}
|
|
/**
|
|
* Register Session Manager
|
|
*/
|
|
register() {
|
|
this.app.container.singleton('Adonis/Addons/Session', () => {
|
|
const { SessionManager } = require('../src/SessionManager');
|
|
return new SessionManager(this.app, this.app.config.get('session', {}));
|
|
});
|
|
}
|
|
/**
|
|
* Register bindings for tests
|
|
*/
|
|
registerTestsBindings() {
|
|
this.app.container.withBindings([
|
|
'Japa/Preset/ApiRequest',
|
|
'Japa/Preset/ApiResponse',
|
|
'Japa/Preset/ApiClient',
|
|
'Adonis/Addons/Session',
|
|
], (ApiRequest, ApiResponse, ApiClient, Session) => {
|
|
const { defineTestsBindings } = require('../src/Bindings/Tests');
|
|
defineTestsBindings(ApiRequest, ApiResponse, ApiClient, Session);
|
|
});
|
|
}
|
|
/**
|
|
* Register server bindings
|
|
*/
|
|
registerServerBindings() {
|
|
this.app.container.withBindings(['Adonis/Core/Server', 'Adonis/Core/HttpContext', 'Adonis/Addons/Session'], (Server, HttpContext, Session) => {
|
|
const { defineServerBindings } = require('../src/Bindings/Server');
|
|
defineServerBindings(HttpContext, Server, Session);
|
|
});
|
|
}
|
|
boot() {
|
|
this.registerServerBindings();
|
|
this.registerTestsBindings();
|
|
}
|
|
}
|
|
exports.default = SessionProvider;
|
|
SessionProvider.needsApplication = true;
|