Skip to content

Commit e5eaf96

Browse files
committed
🔄 Synced local '.' with remote 'apps/examples/express'
1 parent b5a87b5 commit e5eaf96

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

‎src/middleware/auth.middleware.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export async function authenticatedUser(
77
res: Response,
88
next: NextFunction,
99
) {
10-
const session = res.locals.session ?? (await getSession(req, authConfig))
10+
const session =
11+
res.locals.session ?? (await getSession(req, authConfig)) ?? undefined
1112

1213
res.locals.session = session
1314

@@ -23,7 +24,7 @@ export async function currentSession(
2324
res: Response,
2425
next: NextFunction,
2526
) {
26-
const session = await getSession(req, authConfig)
27+
const session = (await getSession(req, authConfig)) ?? undefined
2728
res.locals.session = session
2829
return next()
2930
}

‎tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"outDir": "dist",
1010
"baseUrl": ".",
1111
"skipLibCheck": true,
12-
"strict": true
12+
"strict": true,
13+
"typeRoots": ["types/", "node_modules/@types"]
1314
},
1415
"include": ["src/**/*.ts"],
1516
"exclude": ["node_modules"]

‎types/express/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { type Session } from "@auth/express"
2+
3+
declare module "express" {
4+
interface Response {
5+
locals: {
6+
session?: Session
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)