@things-factory/attachment-base 6.2.38 → 6.2.41

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.
@@ -12,6 +12,8 @@ const { Readable } = require('stream');
12
12
  process.on('bootstrap-module-global-public-route', (app, routes) => {
13
13
  // TODO make this secure
14
14
  routes.get(`/${attachment_const_1.ATTACHMENT_PATH}/:attachment`, async (context, next) => {
15
+ context.set('Cache-Control', 'public, max-age=31536000'); // 캐시 기간 설정 : 1년
16
+ context.set('Expires', new Date(Date.now() + 31536000000).toUTCString()); // 캐시 만료일 설정
15
17
  await attachment_const_1.STORAGE.sendFile(context, context.params.attachment, next);
16
18
  });
17
19
  routes.post(`/${attachment_const_1.ATTACHMENT_PATH}`, upload.any(), async (context, next) => {
@@ -19,7 +21,7 @@ process.on('bootstrap-module-global-public-route', (app, routes) => {
19
21
  const result = await Promise.all(files.map(file => attachment_const_1.STORAGE.uploadFile({ file, context })));
20
22
  context.status = 200;
21
23
  // Support < IE 10 browser
22
- context.res.setHeader('Content-Type', 'text/html;charset=UTF-8');
24
+ context.set('Content-Type', 'text/html;charset=UTF-8');
23
25
  context.body = JSON.stringify(result);
24
26
  });
25
27
  });
@@ -1 +1 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,0BAAuB;AACvB,wBAAqB;AACrB,8BAA2B;AAC3B,gCAA6B;AAE7B,yDAA6D;AAE7D,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AACrC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAA,CAAC,0CAA0C;AAElE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtC,gFAAgF;AAChF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACxE,wBAAwB;IACxB,MAAM,CAAC,GAAG,CAAC,IAAI,kCAAe,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACpE,MAAM,0BAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAClE,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,IAAI,CAAC,IAAI,kCAAe,EAAE,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACvE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QAE3B,MAAM,MAAM,GAAiD,MAAM,OAAO,CAAC,GAAG,CAC5E,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,0BAAO,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CACzD,CAAA;QAED,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;QACpB,0BAA0B;QAC1B,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAA;QAChE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import './storage-file'\nimport './storage-s3'\nimport './storage-database'\nimport './storage-azure-blob'\n\nimport { ATTACHMENT_PATH, STORAGE } from './attachment-const'\n\nconst multer = require('@koa/multer')\nconst upload = multer() // note you can pass `multer` options here\n\nconst { Readable } = require('stream')\n\n// process.on('bootstrap-module-domain-private-route' as any, (app, routes) => {\nprocess.on('bootstrap-module-global-public-route' as any, (app, routes) => {\n // TODO make this secure\n routes.get(`/${ATTACHMENT_PATH}/:attachment`, async (context, next) => {\n await STORAGE.sendFile(context, context.params.attachment, next)\n })\n\n routes.post(`/${ATTACHMENT_PATH}`, upload.any(), async (context, next) => {\n const files = context.files\n\n const result: { id: string; path: string; size: number }[] = await Promise.all(\n files.map(file => STORAGE.uploadFile({ file, context }))\n )\n\n context.status = 200\n // Support < IE 10 browser\n context.res.setHeader('Content-Type', 'text/html;charset=UTF-8')\n context.body = JSON.stringify(result)\n })\n})\n"]}
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,0BAAuB;AACvB,wBAAqB;AACrB,8BAA2B;AAC3B,gCAA6B;AAE7B,yDAA6D;AAE7D,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AACrC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAA,CAAC,0CAA0C;AAElE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtC,gFAAgF;AAChF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACxE,wBAAwB;IACxB,MAAM,CAAC,GAAG,CAAC,IAAI,kCAAe,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACpE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAA,CAAC,gBAAgB;QACzE,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA,CAAC,YAAY;QAErF,MAAM,0BAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAClE,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,IAAI,CAAC,IAAI,kCAAe,EAAE,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACvE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QAE3B,MAAM,MAAM,GAAiD,MAAM,OAAO,CAAC,GAAG,CAC5E,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,0BAAO,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CACzD,CAAA;QAED,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;QACpB,0BAA0B;QAC1B,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAA;QACtD,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import './storage-file'\nimport './storage-s3'\nimport './storage-database'\nimport './storage-azure-blob'\n\nimport { ATTACHMENT_PATH, STORAGE } from './attachment-const'\n\nconst multer = require('@koa/multer')\nconst upload = multer() // note you can pass `multer` options here\n\nconst { Readable } = require('stream')\n\n// process.on('bootstrap-module-domain-private-route' as any, (app, routes) => {\nprocess.on('bootstrap-module-global-public-route' as any, (app, routes) => {\n // TODO make this secure\n routes.get(`/${ATTACHMENT_PATH}/:attachment`, async (context, next) => {\n context.set('Cache-Control', 'public, max-age=31536000') // 캐시 기간 설정 : 1년\n context.set('Expires', new Date(Date.now() + 31536000000).toUTCString()) // 캐시 만료일 설정\n\n await STORAGE.sendFile(context, context.params.attachment, next)\n })\n\n routes.post(`/${ATTACHMENT_PATH}`, upload.any(), async (context, next) => {\n const files = context.files\n\n const result: { id: string; path: string; size: number }[] = await Promise.all(\n files.map(file => STORAGE.uploadFile({ file, context }))\n )\n\n context.status = 200\n // Support < IE 10 browser\n context.set('Content-Type', 'text/html;charset=UTF-8')\n context.body = JSON.stringify(result)\n })\n})\n"]}