Skip to content

Commit

Permalink
Moar ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Veikkosuhonen committed Jan 19, 2024
1 parent d7912d3 commit 7dac25c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"devDependencies": {
"@babel/eslint-parser": "^7.19.1",
"@types/express": "^4.17.21",
"@types/morgan": "^1.9.9",
"@vitest/coverage-v8": "^1.2.1",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { initializeSentry } = require('./util/sentry')
import logger from './util/logger'

const errorHandler = require('./middleware/errors')
const accessLogger = require('./middleware/access')
const accessLogger = require('./middleware/accessLogger')

const {
relevantIAMs,
Expand Down
13 changes: 9 additions & 4 deletions src/middleware/access.js → src/middleware/accessLogger.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const morgan = require('morgan')
const { inProduction } = require('../util/config')
import morgan, { TokenIndexer } from 'morgan'
import logger from '../util/logger'
import { Request, Response } from 'express'
import { inProduction } from '../util/config'

const accessLogger = morgan((tokens, req, res) => {
const formatFunction = (tokens: TokenIndexer, req: Request, res: Response) => {
const { uid } = req.headers

const method = tokens.method(req, res)
Expand All @@ -25,6 +26,10 @@ const accessLogger = morgan((tokens, req, res) => {
: {}

logger.info(message, additionalInfo)
})

return null
}

const accessLogger = morgan(formatFunction)

module.exports = accessLogger

0 comments on commit 7dac25c

Please sign in to comment.