@igea/oac_backend 1.0.91 → 1.0.93

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@igea/oac_backend",
3
- "version": "1.0.91",
3
+ "version": "1.0.93",
4
4
  "description": "Backend service for the OAC project",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -200,13 +200,49 @@ router.post('/upload/vocabularies', upload.array('files'), (req, res) => {
200
200
 
201
201
  });
202
202
 
203
+
204
+ const key = req.params.key;
205
+ const cache = CacheVocabularies.check(key);
206
+
207
+ if (cache.exists) {
208
+ //res.setHeader('Content-Type', 'application/x-www-form-urlencoded');
209
+ //res.sendFile(path.resolve(cache.path));
210
+ res.type('text/turtle');
211
+ console.log("nuova versione "+filePath);
212
+ fs.createReadStream(filePath)
213
+ .on('error', err => {
214
+ console.error('STREAM ERROR:', err.code);
215
+ if (!res.headersSent) {
216
+ res.status(404).send('Cache missing');
217
+ }
218
+ })
219
+ .pipe(res);
220
+
221
+
203
222
  //---------------------------------------------------------------
204
223
  router.get('/get-vocabolary-terms/:key', (req, res) => {
205
224
  const key = req.params.key;
206
225
  const cache = CacheVocabularies.check(key);
226
+ res.set({
227
+ 'Cache-Control': 'no-store, no-cache, must-revalidate, proxy-revalidate',
228
+ 'Pragma': 'no-cache',
229
+ 'Expires': '0',
230
+ 'Surrogate-Control': 'no-store'
231
+ });
207
232
  if(cache.exists){
208
- res.setHeader('Content-Type', 'application/x-www-form-urlencoded');
209
- res.sendFile(path.resolve(cache.path));
233
+ //res.setHeader('Content-Type', 'application/x-www-form-urlencoded');
234
+ //res.sendFile(path.resolve(cache.path));
235
+ const filePath = cache.path;
236
+ res.type('text/turtle');
237
+ //console.log("nuova versione "+filePath);
238
+ fs.createReadStream(filePath)
239
+ .on('error', err => {
240
+ console.error('STREAM ERROR:', err.code);
241
+ if (!res.headersSent) {
242
+ res.status(404).send('Cache missing');
243
+ }
244
+ })
245
+ .pipe(res);
210
246
  }else{
211
247
  const rootIRI = `<http://diagnostica/vocabularies/${key}>`;
212
248
  let _query = `PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>