Skip to content

Commit 79c195e

Browse files
committed
tweak logging
1 parent 89d99b6 commit 79c195e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/utils/auth.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import { logger } from './logger.js'
55
const JWT_SECRET = process.env.JWT_SECRET
66

77
export function logIncomingAuth(req: Request, res: Response, next: NextFunction) {
8-
logger.debug('Incoming headers:', req.headers)
8+
logger.info(
9+
`[AUTH] ${req.headers['cf-connecting-ip'] ?? req.ip} - ${req.headers['cf-ipcountry'] ?? 'unknown country'}`
10+
)
911

1012
const authHeader = req.headers.authorization
1113
if (!authHeader?.startsWith('Bearer ')) {
1214
logger.warn('No auth header or bad format')
15+
logger.debug('Incoming headers:', req.headers)
1316
} else {
1417
const token = authHeader.split(' ')[1]
1518
logger.debug('Inspecting token:', token)

src/utils/rateLimiter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Response } from 'express'
66
export const rateLimiter: RateLimitRequestHandler = rateLimit({
77
windowMs: 60 * 1000,
88
limit: (req: Request): number => {
9-
logger.debug(`Rate limit check ${req.auth ? 'authenticated' : 'anon'} - ${req.headers['cf-connecting-ip'] ?? req.ip}`)
9+
logger.info(`Rate limit check ${req.auth ? 'authenticated' : 'anon'} - ${req.headers['cf-connecting-ip'] ?? req.ip}`)
1010
return req.auth ? 60 : 5 // 60 req/min for auth, 5 for anon
1111
},
1212
keyGenerator: (req: Request): string => {

0 commit comments

Comments
 (0)