@trojs/openapi-server 1.2.5 → 2.0.1
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 +4 -4
- package/src/server.js +7 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trojs/openapi-server",
|
|
3
3
|
"description": "OpenAPI Server",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Pieter Wigboldus",
|
|
7
7
|
"url": "https://trojs.org/"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@hckrnews/eslint-code-quality": "^0.2.1",
|
|
37
37
|
"@hckrnews/eslint-config": "^3.1.0",
|
|
38
38
|
"@types/express-serve-static-core": "^4.17.41",
|
|
39
|
-
"@types/node": "^
|
|
39
|
+
"@types/node": "^22.0.0",
|
|
40
40
|
"c8": "^10.0.0",
|
|
41
41
|
"eslint": "^8.23.0",
|
|
42
42
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
"express"
|
|
67
67
|
],
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@sentry/node": "^
|
|
69
|
+
"@sentry/node": "^8.0.0",
|
|
70
70
|
"ajv-formats": "^3.0.0",
|
|
71
71
|
"body-parser": "^2.0.0",
|
|
72
72
|
"compression": "^1.7.4",
|
|
73
73
|
"cors": "^2.8.5",
|
|
74
74
|
"express": "^4.19.2",
|
|
75
|
-
"helmet": "^
|
|
75
|
+
"helmet": "^8.0.0",
|
|
76
76
|
"openapi-backend": "^5.9.2",
|
|
77
77
|
"swagger-ui-express": "^5.0.0"
|
|
78
78
|
},
|
package/src/server.js
CHANGED
|
@@ -29,6 +29,7 @@ const getOriginResourcePolicy = (origin) => ({
|
|
|
29
29
|
* @typedef {import('./api.js').ApiSchema} ApiSchema
|
|
30
30
|
* @typedef {import('./api.js').Logger} Logger
|
|
31
31
|
* @typedef {import('express').Express} Express
|
|
32
|
+
* @typedef {import('@sentry/types').Integration} Integration
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -51,6 +52,7 @@ const getOriginResourcePolicy = (origin) => ({
|
|
|
51
52
|
* @property {number=} tracesSampleRate
|
|
52
53
|
* @property {number=} profilesSampleRate
|
|
53
54
|
* @property {string=} release
|
|
55
|
+
* @property {Integration[]=} integrations
|
|
54
56
|
*/
|
|
55
57
|
|
|
56
58
|
/**
|
|
@@ -64,6 +66,7 @@ const getOriginResourcePolicy = (origin) => ({
|
|
|
64
66
|
* @param {string=} params.poweredBy
|
|
65
67
|
* @param {string=} params.version
|
|
66
68
|
* @param {any[]=} params.middleware
|
|
69
|
+
* @param {string=} params.maximumBodySize
|
|
67
70
|
* @returns {Promise<{ app: Express }>}
|
|
68
71
|
*/
|
|
69
72
|
export const setupServer = async ({
|
|
@@ -74,6 +77,7 @@ export const setupServer = async ({
|
|
|
74
77
|
poweredBy = 'TroJS',
|
|
75
78
|
version = '1.0.0',
|
|
76
79
|
middleware = [],
|
|
80
|
+
maximumBodySize = '5mb',
|
|
77
81
|
}) => {
|
|
78
82
|
const corsOptions = {
|
|
79
83
|
origin,
|
|
@@ -84,16 +88,11 @@ export const setupServer = async ({
|
|
|
84
88
|
if (sentry) {
|
|
85
89
|
Sentry.init({
|
|
86
90
|
dsn: sentry.dsn,
|
|
87
|
-
integrations: [
|
|
88
|
-
new Sentry.Integrations.Http({ tracing: true }),
|
|
89
|
-
new Sentry.Integrations.Express({ app }),
|
|
90
|
-
],
|
|
91
91
|
tracesSampleRate: sentry.tracesSampleRate || 1.0,
|
|
92
92
|
profilesSampleRate: sentry.profilesSampleRate || 1.0,
|
|
93
|
+
integrations: sentry.integrations || [],
|
|
93
94
|
release: sentry.release,
|
|
94
95
|
});
|
|
95
|
-
|
|
96
|
-
app.use(Sentry.Handlers.requestHandler());
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
app.use(cors(corsOptions));
|
|
@@ -101,7 +100,7 @@ export const setupServer = async ({
|
|
|
101
100
|
app.use(helmet(getOriginResourcePolicy(origin)));
|
|
102
101
|
app.use(express.json());
|
|
103
102
|
middleware.forEach((fn) => app.use(fn));
|
|
104
|
-
app.use(bodyParser.urlencoded({ extended: false }));
|
|
103
|
+
app.use(bodyParser.urlencoded({ extended: false, limit: maximumBodySize }));
|
|
105
104
|
app.use((_request, response, next) => {
|
|
106
105
|
response.setHeader('X-Powered-By', poweredBy);
|
|
107
106
|
response.setHeader('X-Version', version);
|
|
@@ -119,7 +118,7 @@ export const setupServer = async ({
|
|
|
119
118
|
});
|
|
120
119
|
|
|
121
120
|
if (sentry) {
|
|
122
|
-
|
|
121
|
+
Sentry.setupExpressErrorHandler(app);
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
return { app };
|