@trojs/openapi-server 1.15.0 → 1.17.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.15.0",
4
+ "version": "1.17.0",
5
5
  "author": {
6
6
  "name": "Pieter Wigboldus",
7
7
  "url": "https://trojs.org/"
@@ -11,6 +11,10 @@ const errorCodesStatus = [
11
11
  type: RangeError,
12
12
  status: 404
13
13
  },
14
+ {
15
+ type: SyntaxError,
16
+ status: 400
17
+ },
14
18
  {
15
19
  type: Error,
16
20
  status: 500
@@ -99,6 +99,7 @@ export const makeExpressCallback
99
99
  }
100
100
 
101
101
  return {
102
+ errors: error.errors || error.value?.errors,
102
103
  status: errorCodeStatus,
103
104
  timestamp: new Date(),
104
105
  message: error.message
package/src/server.js CHANGED
@@ -4,6 +4,7 @@ import compression from 'compression'
4
4
  import helmet from 'helmet'
5
5
  import * as Sentry from '@sentry/node'
6
6
  import bodyParser from 'body-parser'
7
+ import { hostname } from 'node:os'
7
8
  import { openAPI } from './openapi.js'
8
9
  import { Api } from './api.js'
9
10
 
@@ -53,6 +54,8 @@ const getOriginResourcePolicy = (origin) => ({
53
54
  * @property {number=} tracesSampleRate
54
55
  * @property {number=} profilesSampleRate
55
56
  * @property {string=} release
57
+ * @property {string=} environment
58
+ * @property {string=} serverName
56
59
  */
57
60
 
58
61
  /**
@@ -88,13 +91,15 @@ export const setupServer = async ({
88
91
  if (sentry) {
89
92
  Sentry.init({
90
93
  dsn: sentry.dsn,
94
+ environment: sentry.environment || process.env.NODE_ENV || 'production',
91
95
  integrations: [
92
96
  new Sentry.Integrations.Http({ tracing: true }),
93
97
  new Sentry.Integrations.Express({ app })
94
98
  ],
95
99
  tracesSampleRate: sentry.tracesSampleRate || 1.0,
96
100
  profilesSampleRate: sentry.profilesSampleRate || 1.0,
97
- release: sentry.release
101
+ release: sentry.release || process.env.SOURCE_VERSION,
102
+ serverName: sentry.serverName || process.env.SERVER_NAME || hostname()
98
103
  })
99
104
 
100
105
  app.use(Sentry.Handlers.requestHandler())
@@ -1 +1 @@
1
- {"version":3,"file":"error-status.d.ts","sourceRoot":"","sources":["../src/error-status.js"],"names":[],"mappings":"AAyBe,iCAHJ,WAAW,GACT,MAAM,CAKX;;0BA3BK,KAAK,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE"}
1
+ {"version":3,"file":"error-status.d.ts","sourceRoot":"","sources":["../src/error-status.js"],"names":[],"mappings":"AA6Be,iCAHJ,WAAW,GACT,MAAM,CAKX;;0BA/BK,KAAK,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE"}
@@ -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,YAoFE;sBArGQ,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":"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"}
package/types/server.d.ts CHANGED
@@ -32,6 +32,8 @@ export type SentryConfig = {
32
32
  tracesSampleRate?: number | undefined;
33
33
  profilesSampleRate?: number | undefined;
34
34
  release?: string | undefined;
35
+ environment?: string | undefined;
36
+ serverName?: string | undefined;
35
37
  };
36
38
  import { openAPI } from './openapi.js';
37
39
  import { Api } from './api.js';
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.js"],"names":[],"mappings":"AAuEO,qHAVJ;IAA4B,IAAI,EAAxB,SAAS,EAAE;IACK,MAAM,GAAtB,MAAM,YAAC;IACS,YAAY,GAA5B,MAAM,YAAC;IACe,MAAM,GAA5B,YAAY,YAAC;IACG,SAAS,GAAzB,MAAM,YAAC;IACS,OAAO,GAAvB,MAAM,YAAC;IACQ,UAAU,GAAzB,GAAG,EAAE,YAAC;IACiB,eAAe,GAAtC,CAAA,MAAM,GAAC,MAAM,aAAC;CACtB,GAAU,OAAO,CAAC;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC,CA4DrC;sBAtGY,OAAO,2BAA2B,EAAE,OAAO;uBAC3C,OAAO,2BAA2B,EAAE,QAAQ;sBAC5C,OAAO,iBAAiB,EAAE,OAAO;wBACjC,OAAO,UAAU,EAAE,SAAS;qBAC5B,OAAO,UAAU,EAAE,MAAM;;uBAKxB,CAAC;cAED,OAAO,YAAC;cACR,OAAO,YAAC;eACR,QAAQ,YAAC;iBACT,MAAM,YAAC;oBACP,MAAM,YAAC;WACP,CAAC,YAAC;UACF,MAAM,YAAC;aACP,MAAM,YAAC;WACP,MAAM,YAAC;;;UAKP,MAAM,YAAC;uBACP,MAAM,YAAC;yBACP,MAAM,YAAC;cACP,MAAM,YAA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