Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make session macroable #84

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * as errors from './src/errors.js'
export { configure } from './configure.js'
export { stubsRoot } from './stubs/main.js'
export { defineConfig, stores } from './src/define_config.js'
export { Session } from './src/session.js'
5 changes: 4 additions & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { cuid } from '@adonisjs/core/helpers'
import type { HttpContext } from '@adonisjs/core/http'
import type { EmitterService } from '@adonisjs/core/types'
import type { HttpError } from '@adonisjs/core/types/http'
import Macroable from '@poppinss/macroable'

import debug from './debug.js'
import * as errors from './errors.js'
Expand All @@ -32,7 +33,7 @@ import type {
* A session instance is isolated between requests but
* uses a centralized persistence store and
*/
export class Session {
export class Session extends Macroable {
#store: SessionStoreContract
#emitter: EmitterService
#ctx: HttpContext
Expand Down Expand Up @@ -135,6 +136,8 @@ export class Session {
emitter: EmitterService,
ctx: HttpContext
) {
super()

this.#ctx = ctx
this.#emitter = emitter
this.#store = storeFactory(ctx, config)
Expand Down
Loading