cloudcommerce 0.0.79 → 0.0.81

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.81](https://github.com/ecomplus/cloud-commerce/compare/v0.0.80...v0.0.81) (2022-09-16)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **ssr:** Use `compression` pkg (middleware) to gzip ([714c8b3](https://github.com/ecomplus/cloud-commerce/commit/714c8b3f502082a6a395b40e7a792540cd9af861))
11
+
12
+ ### [0.0.80](https://github.com/ecomplus/cloud-commerce/compare/v0.0.79...v0.0.80) (2022-09-16)
13
+
5
14
  ### [0.0.79](https://github.com/ecomplus/cloud-commerce/compare/v0.0.78...v0.0.79) (2022-09-16)
6
15
 
7
16
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloudcommerce",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "Open fair-code headless commerce platform: API-first, microservices based, event driven and cloud native",
6
6
  "main": "packages/api/lib/index.js",
7
7
  "author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/api.js",
7
7
  "types": "lib/api.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-correios",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce app for Correios shipping calculation",
6
6
  "main": "lib/correios.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-custom-shipping",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce app for custom shipping methods",
6
6
  "main": "lib/custom-shipping.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-discounts",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce app for complex discount rules",
6
6
  "main": "lib/discounts.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-frenet",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce app for Frenet shipping calculation",
6
6
  "main": "lib/frenet.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-tiny-erp",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce app for Tiny ERP",
6
6
  "main": "lib/tiny-erp.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/cli",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce CLI tools",
6
6
  "bin": {
7
7
  "cloudcommerce": "./bin/run.mjs"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/config",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce base config",
6
6
  "main": "lib/config.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/events",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce app events",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/firebase",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce on Firebase",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/modules",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce modules API",
6
6
  "main": "lib/index.cjs",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/passport",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce customers authentication (passport) API",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,16 +1,18 @@
1
- import { join as joinPath } from 'node:path';
2
- import { readFile } from 'node:fs/promises';
3
- import { gzip } from 'node:zlib';
4
- import logger from 'firebase-functions/lib/logger';
1
+ import { join as joinPath } from 'path';
2
+ import { readFile } from 'fs/promises';
3
+ import compression from 'compression';
5
4
 
6
5
  const { STOREFRONT_BASE_DIR } = process.env;
7
6
  const baseDir = STOREFRONT_BASE_DIR || process.cwd();
8
7
  const clientRoot = new URL(joinPath(baseDir, 'dist/client/'), import.meta.url);
8
+ const compress = compression();
9
9
 
10
10
  export default (req, res) => {
11
11
  const url = req.url.replace(/\?.*$/, '').replace(/\.html$/, '');
12
12
  const setStatusAndCache = (status, defaultCache) => {
13
- return res.status(status).set('Cache-Control', (typeof global.cache_control === 'function' && global.cache_control(status))
13
+ return res.status(status)
14
+ .set('X-SSR-ID', `v1/${Date.now()}`)
15
+ .set('Cache-Control', (typeof global.cache_control === 'function' && global.cache_control(status))
14
16
  || defaultCache);
15
17
  };
16
18
  const fallback = (err, status = 500) => {
@@ -25,46 +27,27 @@ export default (req, res) => {
25
27
  .send(err.toString());
26
28
  }
27
29
  };
28
- res.WRITEHEAD = res.writeHead;
29
- res.writeHead = (statusCode, headers) => {
30
- if (headers && typeof headers === 'object' && !Array.isArray(headers)) {
31
- delete headers['transfer-encoding'];
32
- headers['Transfer-Encoding'] = 'gzip, chunked';
33
- headers['X-SSR-ID'] = `v1/${Date.now()}`;
34
- }
35
- return res.WRITEHEAD(statusCode, headers);
36
- };
37
- res.WRITE = res.write;
38
- res.write = (chunk) => {
39
- gzip(chunk, (err, data) => {
30
+ compress(req, res, async () => {
31
+ /*
32
+ https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
33
+ import { handler as ssrHandler } from '../dist/server/entry.mjs';
34
+ global.ssr_handler = ssrHandler;
35
+ */
36
+ global.ssr_handler(req, res, async (err) => {
40
37
  if (err) {
41
- logger.error(err);
38
+ res.set('X-SSR-Error', err.message);
42
39
  fallback(err);
43
- } else {
44
- res.WRITE(data);
40
+ return;
41
+ }
42
+ const local = new URL(`.${url}`, clientRoot);
43
+ try {
44
+ const data = await readFile(local);
45
+ setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
46
+ .send(data);
47
+ } catch {
48
+ fallback(err, 404);
45
49
  }
46
50
  });
47
- return true;
48
- };
49
- /*
50
- https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
51
- import { handler as ssrHandler } from '../dist/server/entry.mjs';
52
- global.ssr_handler = ssrHandler;
53
- */
54
- global.ssr_handler(req, res, async (err) => {
55
- if (err) {
56
- res.set('X-SSR-Error', err.message);
57
- fallback(err);
58
- return;
59
- }
60
- const local = new URL(`.${url}`, clientRoot);
61
- try {
62
- const data = await readFile(local);
63
- setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
64
- .send(data);
65
- } catch {
66
- fallback(err, 404);
67
- }
68
51
  });
69
52
  };
70
53
  // # sourceMappingURL=serve-storefront.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serve-storefront.js","sourceRoot":"","sources":["../../src/firebase/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AC,CAAC;gBACd,OAAO;aACR;YACD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;YAC7C,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACnC,iBAAiB,CAAC,GAAG,EAAE,kCAAkC,CAAC;qBACvD,IAAI,CAAC,IAAI,CAAC,CAAC;aACf;YAAC,MAAM;gBACN,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;aACpB;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -25,6 +25,7 @@
25
25
  "dependencies": {
26
26
  "@cloudcommerce/api": "workspace:*",
27
27
  "@cloudcommerce/firebase": "workspace:*",
28
+ "compression": "^1.7.4",
28
29
  "firebase-admin": "^11.0.1",
29
30
  "firebase-functions": "^3.23.0",
30
31
  "source-map-support": "^0.5.21"
@@ -1,28 +1,24 @@
1
1
  import type { Request, Response } from 'firebase-functions';
2
- import type { OutgoingHttpHeaders, OutgoingHttpHeader } from 'node:http';
3
- import { join as joinPath } from 'node:path';
4
- import { readFile } from 'node:fs/promises';
5
- import { gzip } from 'node:zlib';
6
- import logger from 'firebase-functions/lib/logger';
2
+ import { join as joinPath } from 'path';
3
+ import { readFile } from 'fs/promises';
4
+ import compression from 'compression';
7
5
 
8
6
  const { STOREFRONT_BASE_DIR } = process.env;
9
7
  const baseDir = STOREFRONT_BASE_DIR || process.cwd();
10
8
  const clientRoot = new URL(joinPath(baseDir, 'dist/client/'), import.meta.url);
9
+ const compress = compression();
11
10
 
12
- type InterceptedResponse = Response & {
13
- WRITEHEAD?: Response['writeHead'],
14
- WRITE?: Response['write'],
15
- };
16
-
17
- export default (req: Request, res: InterceptedResponse) => {
11
+ export default (req: Request, res: Response) => {
18
12
  const url = req.url.replace(/\?.*$/, '').replace(/\.html$/, '');
19
13
 
20
14
  const setStatusAndCache = (status: number, defaultCache: string) => {
21
- return res.status(status).set(
22
- 'Cache-Control',
23
- (typeof global.cache_control === 'function' && global.cache_control(status))
24
- || defaultCache,
25
- );
15
+ return res.status(status)
16
+ .set('X-SSR-ID', `v1/${Date.now()}`)
17
+ .set(
18
+ 'Cache-Control',
19
+ (typeof global.cache_control === 'function' && global.cache_control(status))
20
+ || defaultCache,
21
+ );
26
22
  };
27
23
 
28
24
  const fallback = (err: any, status = 500) => {
@@ -38,53 +34,26 @@ export default (req: Request, res: InterceptedResponse) => {
38
34
  }
39
35
  };
40
36
 
41
- res.WRITEHEAD = res.writeHead;
42
- res.writeHead = (
43
- statusCode: number,
44
- headers?: string | OutgoingHttpHeaders | OutgoingHttpHeader[],
45
- ) => {
46
- if (headers && typeof headers === 'object' && !Array.isArray(headers)) {
47
- delete headers['transfer-encoding'];
48
- headers['Transfer-Encoding'] = 'gzip, chunked';
49
- headers['X-SSR-ID'] = `v1/${Date.now()}`;
50
- }
51
- return (res.WRITEHEAD as Response['writeHead'])(
52
- statusCode,
53
- headers as OutgoingHttpHeaders,
54
- );
55
- };
56
-
57
- res.WRITE = res.write;
58
- res.write = (chunk: any) => {
59
- gzip(chunk, (err, data) => {
37
+ compress(req, res, async () => {
38
+ /*
39
+ https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
40
+ import { handler as ssrHandler } from '../dist/server/entry.mjs';
41
+ global.ssr_handler = ssrHandler;
42
+ */
43
+ global.ssr_handler(req, res, async (err: any) => {
60
44
  if (err) {
61
- logger.error(err);
45
+ res.set('X-SSR-Error', err.message);
62
46
  fallback(err);
63
- } else {
64
- (res.WRITE as Response['write'])(data);
47
+ return;
48
+ }
49
+ const local = new URL(`.${url}`, clientRoot);
50
+ try {
51
+ const data = await readFile(local);
52
+ setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
53
+ .send(data);
54
+ } catch {
55
+ fallback(err, 404);
65
56
  }
66
57
  });
67
- return true;
68
- };
69
-
70
- /*
71
- https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
72
- import { handler as ssrHandler } from '../dist/server/entry.mjs';
73
- global.ssr_handler = ssrHandler;
74
- */
75
- global.ssr_handler(req, res, async (err: any) => {
76
- if (err) {
77
- res.set('X-SSR-Error', err.message);
78
- fallback(err);
79
- return;
80
- }
81
- const local = new URL(`.${url}`, clientRoot);
82
- try {
83
- const data = await readFile(local);
84
- setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
85
- .send(data);
86
- } catch {
87
- fallback(err, 404);
88
- }
89
58
  });
90
59
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "main": "src/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/types",
3
3
  "type": "module",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {