@jsreport/jsreport-express
Advanced tools
Comparing version 3.3.1 to 3.4.0
@@ -53,2 +53,8 @@ | ||
type: 'object' | ||
}, | ||
cors: { | ||
type: 'object', | ||
properties: { | ||
enabled: { type: 'boolean', default: true } | ||
} | ||
} | ||
@@ -55,0 +61,0 @@ } |
@@ -143,8 +143,10 @@ /*! | ||
app.options('*', (req, res) => { | ||
require('cors')({ | ||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'MERGE'], | ||
origin: true | ||
})(req, res) | ||
}) | ||
if (definition.options.cors?.enabled !== false) { | ||
app.options('*', (req, res) => { | ||
require('cors')({ | ||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'MERGE'], | ||
origin: true | ||
})(req, res) | ||
}) | ||
} | ||
@@ -161,6 +163,10 @@ app.use(cookieParser()) | ||
app.use(cors()) | ||
if (definition.options.cors?.enabled !== false) { | ||
app.use(cors()) | ||
} | ||
app.use((req, res, next) => { | ||
res.setHeader('Access-Control-Expose-Headers', '*') | ||
if (definition.options.cors?.enabled !== false) { | ||
res.setHeader('Access-Control-Expose-Headers', '*') | ||
} | ||
@@ -279,5 +285,7 @@ if (definition.options.responseHeaders) { | ||
reporter.afterRenderListeners.add('express', (req, res) => { | ||
res.meta.profileId = res.meta.headers['Profile-Id'] = res.meta.profileId | ||
if (req.context.http) { | ||
res.meta.headers['Profile-Location'] = `${req.context.http.baseUrl}/api/profile/${res.meta.profileId}` | ||
if (res.meta.profileId) { | ||
res.meta.profileId = res.meta.headers['Profile-Id'] = res.meta.profileId | ||
if (req.context.http) { | ||
res.meta.headers['Profile-Location'] = `${req.context.http.baseUrl}/api/profile/${res.meta.profileId}` | ||
} | ||
} | ||
@@ -284,0 +292,0 @@ }) |
@@ -34,3 +34,3 @@ const { pipeline } = require('stream') | ||
function httpRender (renderRequestContent, req, res, stream, next) { | ||
res.setTimeout((reporter.options.reportTimeout + reporter.options.reportTimeoutMargin) * 1.2) | ||
res.setTimeout((reporter.getReportTimeout(req) + reporter.options.reportTimeoutMargin) * 1.2) | ||
res.setHeader('X-XSS-Protection', 0) | ||
@@ -202,7 +202,8 @@ | ||
if (!profile.blobPersisted) { | ||
// try to wait until the events are fully flushed | ||
if (profile.state !== 'success' && profile.state !== 'error') { | ||
for (let i = 0; i < 10; i++) { | ||
await new Promise((resolve) => setTimeout(resolve, 500)) | ||
profile = await reporter.documentStore.collection('profiles').findOne({ _id: req.params.id }, req) | ||
if (profile.blobPersisted) { | ||
if (profile.state === 'success' || profile.state === 'error') { | ||
break | ||
@@ -212,3 +213,3 @@ } | ||
if (!profile.blobPersisted) { | ||
if (profile.state !== 'success' && profile.state !== 'error') { | ||
throw reporter.createError('Timeout when waiting for profile blob to be fully persisted') | ||
@@ -252,7 +253,8 @@ } | ||
if (!profile.blobPersisted) { | ||
// try to wait until the events are fully flushed | ||
if (profile.state !== 'success' && profile.state !== 'error') { | ||
for (let i = 0; i < 10; i++) { | ||
await new Promise((resolve) => setTimeout(resolve, 500)) | ||
profile = await reporter.documentStore.collection('profiles').findOne({ _id: req.params.id }, req) | ||
if (profile.blobPersisted) { | ||
if (profile.state === 'success' || profile.state === 'error') { | ||
break | ||
@@ -262,3 +264,3 @@ } | ||
if (!profile.blobPersisted) { | ||
if (profile.state !== 'success' && profile.state !== 'error') { | ||
throw reporter.createError('Timeout when waiting for profile blob to be fully persisted') | ||
@@ -265,0 +267,0 @@ } |
{ | ||
"name": "@jsreport/jsreport-express", | ||
"version": "3.3.1", | ||
"version": "3.4.0", | ||
"description": "jsreport extension adding API", | ||
@@ -42,3 +42,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@jsreport/jsreport-core": "3.4.1", | ||
"@jsreport/jsreport-core": "3.5.0", | ||
"@jsreport/jsreport-jsrender": "3.0.0", | ||
@@ -45,0 +45,0 @@ "@jsreport/jsreport-scripts": "3.2.0", |
@@ -10,2 +10,7 @@ # @jsreport/jsreport-express | ||
### 3.4.0 | ||
- add option `extensions.express.cors.enabled` to enable/disable cors handling in jsreport | ||
- fix applying req.options.timeout when enableRequestReportTimeout is true | ||
### 3.3.1 | ||
@@ -12,0 +17,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57088
1248
35