@trojs/openapi-server 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trojs/openapi-server",
3
3
  "description": "OpenAPI Server",
4
- "version": "1.17.0",
4
+ "version": "1.18.0",
5
5
  "author": {
6
6
  "name": "Pieter Wigboldus",
7
7
  "url": "https://trojs.org/"
@@ -54,7 +54,7 @@
54
54
  "url": "https://github.com/trojs/openapi-server"
55
55
  },
56
56
  "engines": {
57
- "node": ">= 20 < 21 || >= 22 < 23"
57
+ "node": ">= 20 < 21 || >= 22 < 23 || >= 24 < 25"
58
58
  },
59
59
  "keywords": [
60
60
  "openapi",
@@ -1,3 +1,4 @@
1
+ /* eslint-disable complexity */
1
2
  import { hrtime } from 'node:process'
2
3
  import getStatusByError from './error-status.js'
3
4
  import { parseParams } from './params.js'
@@ -45,6 +46,15 @@ export const makeExpressCallback
45
46
  mock
46
47
  })
47
48
  const url = `${request.protocol}://${request.get('Host')}${request.originalUrl}`
49
+
50
+ const ipHeader = request.headers?.['x-forwarded-for']
51
+ const ipString = Array.isArray(ipHeader) ? ipHeader[0] : ipHeader
52
+ const ip = ipString
53
+ ? ipString.split(',')[0].trim()
54
+ : (request.socket?.remoteAddress || request.ip || '-')
55
+ const { method } = request
56
+ const userAgent = request.headers?.['user-agent'] || request.get('user-agent') || '-'
57
+
48
58
  const feedback = {
49
59
  context,
50
60
  request,
@@ -68,7 +78,13 @@ export const makeExpressCallback
68
78
  url,
69
79
  parameters,
70
80
  post: request.body,
71
- response: responseBody
81
+ response: responseBody,
82
+ method,
83
+ ip,
84
+ userAgent,
85
+ responseTime,
86
+ statusCode: response.statusCode || 200,
87
+ message: 'access'
72
88
  })
73
89
 
74
90
  return responseBody
@@ -1 +1 @@
1
- {"version":3,"file":"express-callback.d.ts","sourceRoot":"","sources":["../src/express-callback.js"],"names":[],"mappings":"AAwBO,sHAVJ;IAAyB,UAAU;IACZ,aAAa,EAA5B,MAAM;IACW,YAAY,GAA7B,OAAO,YAAC;IACQ,MAAM,GAAtB,MAAM,YAAC;IACS,IAAI,GAApB,MAAM,YAAC;IACU,IAAI,GAArB,OAAO,YAAC;IACU,MAAM,GAAxB,oBAAS;IACS,OAAO,GAAzB,oBAAS;CACjB,YAqFE;sBAtGQ,OAAO,2BAA2B,EAAE,OAAO;uBAC3C,OAAO,2BAA2B,EAAE,QAAQ;sBAC5C,OAAO,iBAAiB,EAAE,OAAO;qBACjC,OAAO,UAAU,EAAE,MAAM"}
1
+ {"version":3,"file":"express-callback.d.ts","sourceRoot":"","sources":["../src/express-callback.js"],"names":[],"mappings":"AAyBO,sHAVJ;IAAyB,UAAU;IACZ,aAAa,EAA5B,MAAM;IACW,YAAY,GAA7B,OAAO,YAAC;IACQ,MAAM,GAAtB,MAAM,YAAC;IACS,IAAI,GAApB,MAAM,YAAC;IACU,IAAI,GAArB,OAAO,YAAC;IACU,MAAM,GAAxB,oBAAS;IACS,OAAO,GAAzB,oBAAS;CACjB,YAoGE;sBArHQ,OAAO,2BAA2B,EAAE,OAAO;uBAC3C,OAAO,2BAA2B,EAAE,QAAQ;sBAC5C,OAAO,iBAAiB,EAAE,OAAO;qBACjC,OAAO,UAAU,EAAE,MAAM"}