Skip to content

Commit

Permalink
refactor: move name option inside cookieOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lordfirespeed committed Aug 27, 2024
1 parent 0f7c8f6 commit 0a17e5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export default function session<
>(options: Options = {}) {
type TypedSession = Session<T>

const name = options.name || "sid"
const store = options.store || new MemoryStore()
const genId = options.genid || nanoid
const touchAfter = options.touchAfter ?? -1
const { unsign, ...cookieOpts } = options.cookie ?? {}
const { name: maybeName, unsign, ...cookieOpts } = options.cookie ?? {}
const name = maybeName ?? "sid"

function decorateSession(req: Req, res: Res, session: TypedSession, id: string, _now: number) {
Object.defineProperties(session, {
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ export interface SessionStore {
}

export interface Options {
name?: string | undefined
store?: SessionStore | undefined
genid?: (() => string) | undefined
touchAfter?: number | undefined
cookie?:
| (Partial<Exclude<Cookie, "expires">> & {
name?: string | undefined

/**
* `otterhttp` cookie `sign` function, will be passed to `res.cookie`.
* @default undefined
Expand Down

0 comments on commit 0a17e5c

Please sign in to comment.