Skip to content

Commit 0a17e5c

Browse files
committed
refactor: move name option inside cookieOptions
1 parent 0f7c8f6 commit 0a17e5c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export default function session<
1313
>(options: Options = {}) {
1414
type TypedSession = Session<T>
1515

16-
const name = options.name || "sid"
1716
const store = options.store || new MemoryStore()
1817
const genId = options.genid || nanoid
1918
const touchAfter = options.touchAfter ?? -1
20-
const { unsign, ...cookieOpts } = options.cookie ?? {}
19+
const { name: maybeName, unsign, ...cookieOpts } = options.cookie ?? {}
20+
const name = maybeName ?? "sid"
2121

2222
function decorateSession(req: Req, res: Res, session: TypedSession, id: string, _now: number) {
2323
Object.defineProperties(session, {

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ export interface SessionStore {
3838
}
3939

4040
export interface Options {
41-
name?: string | undefined
4241
store?: SessionStore | undefined
4342
genid?: (() => string) | undefined
4443
touchAfter?: number | undefined
4544
cookie?:
4645
| (Partial<Exclude<Cookie, "expires">> & {
46+
name?: string | undefined
47+
4748
/**
4849
* `otterhttp` cookie `sign` function, will be passed to `res.cookie`.
4950
* @default undefined

0 commit comments

Comments
 (0)