cloudcommerce 0.0.78 → 0.0.79
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 +8 -0
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/lib/firebase/serve-storefront.js +27 -6
- package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
- package/packages/ssr/lib/firebase.js +2 -2
- package/packages/ssr/package.json +1 -1
- package/packages/ssr/src/firebase/serve-storefront.ts +45 -10
- package/packages/ssr/src/firebase.ts +2 -2
- package/packages/storefront/dist/client/assets/{_...04e396d7.css → _...11681504.css} +2 -2
- package/packages/storefront/dist/client/hoisted.31e23ac0.js +271 -0
- package/packages/storefront/dist/server/entry.mjs +9 -9
- package/packages/storefront/package.json +5 -5
- package/packages/storefront/src/lib/layouts/Base.astro +1 -5
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/hoisted.61a32b69.js +0 -661
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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.79](https://github.com/ecomplus/cloud-commerce/compare/v0.0.78...v0.0.79) (2022-09-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **ssr:** Hardset default function memory 256MiB ([ae250d8](https://github.com/ecomplus/cloud-commerce/commit/ae250d8532987f33ddd6320a60b2c02331dbc2c3))
|
|
11
|
+
* **storefront:** Update Astro, Vite and other non-major dependencies ([7ee3936](https://github.com/ecomplus/cloud-commerce/commit/7ee393694173a3c10c7fdaba1e069342845e90cd))
|
|
12
|
+
|
|
5
13
|
### [0.0.78](https://github.com/ecomplus/cloud-commerce/compare/v0.0.77...v0.0.78) (2022-09-15)
|
|
6
14
|
|
|
7
15
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcommerce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.79",
|
|
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,5 +1,7 @@
|
|
|
1
|
-
import { join as joinPath } from 'path';
|
|
2
|
-
import { readFile } from 'fs/promises';
|
|
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';
|
|
3
5
|
|
|
4
6
|
const { STOREFRONT_BASE_DIR } = process.env;
|
|
5
7
|
const baseDir = STOREFRONT_BASE_DIR || process.cwd();
|
|
@@ -8,9 +10,7 @@ const clientRoot = new URL(joinPath(baseDir, 'dist/client/'), import.meta.url);
|
|
|
8
10
|
export default (req, res) => {
|
|
9
11
|
const url = req.url.replace(/\?.*$/, '').replace(/\.html$/, '');
|
|
10
12
|
const setStatusAndCache = (status, defaultCache) => {
|
|
11
|
-
return res.status(status)
|
|
12
|
-
.set('X-SSR-ID', `v1/${Math.random()}`)
|
|
13
|
-
.set('Cache-Control', (typeof global.cache_control === 'function' && global.cache_control(status))
|
|
13
|
+
return res.status(status).set('Cache-Control', (typeof global.cache_control === 'function' && global.cache_control(status))
|
|
14
14
|
|| defaultCache);
|
|
15
15
|
};
|
|
16
16
|
const fallback = (err, status = 500) => {
|
|
@@ -25,7 +25,28 @@ export default (req, res) => {
|
|
|
25
25
|
.send(err.toString());
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
|
|
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) => {
|
|
40
|
+
if (err) {
|
|
41
|
+
logger.error(err);
|
|
42
|
+
fallback(err);
|
|
43
|
+
} else {
|
|
44
|
+
res.WRITE(data);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
/*
|
|
29
50
|
https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
|
|
30
51
|
import { handler as ssrHandler } from '../dist/server/entry.mjs';
|
|
31
52
|
global.ssr_handler = ssrHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-storefront.js","sourceRoot":"","sources":["../../src/firebase/serve-storefront.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serve-storefront.js","sourceRoot":"","sources":["../../src/firebase/serve-storefront.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACj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OAAO;SACR;QACD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QAC7C,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;YACnC,iBAAiB,CAAC,GAAG,EAAE,kCAAkC,CAAC;iBACvD,IAAI,CAAC,IAAI,CAAC,CAAC;SACf;QAAC,MAAM;YACN,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SACpB;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -8,8 +8,8 @@ import serveStorefront from './firebase/serve-storefront.js';
|
|
|
8
8
|
const { httpsFunctionOptions } = config.get();
|
|
9
9
|
|
|
10
10
|
export const ssr = onRequest({
|
|
11
|
-
timeoutSeconds:
|
|
12
|
-
memory: '
|
|
11
|
+
timeoutSeconds: 15,
|
|
12
|
+
memory: '256MiB',
|
|
13
13
|
// minInstances: 1,
|
|
14
14
|
...httpsFunctionOptions,
|
|
15
15
|
}, (req, res) => {
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import type { Request, Response } from 'firebase-functions';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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';
|
|
4
7
|
|
|
5
8
|
const { STOREFRONT_BASE_DIR } = process.env;
|
|
6
9
|
const baseDir = STOREFRONT_BASE_DIR || process.cwd();
|
|
7
10
|
const clientRoot = new URL(joinPath(baseDir, 'dist/client/'), import.meta.url);
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
type InterceptedResponse = Response & {
|
|
13
|
+
WRITEHEAD?: Response['writeHead'],
|
|
14
|
+
WRITE?: Response['write'],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default (req: Request, res: InterceptedResponse) => {
|
|
10
18
|
const url = req.url.replace(/\?.*$/, '').replace(/\.html$/, '');
|
|
11
19
|
|
|
12
20
|
const setStatusAndCache = (status: number, defaultCache: string) => {
|
|
13
|
-
return res.status(status)
|
|
14
|
-
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|| defaultCache,
|
|
19
|
-
);
|
|
21
|
+
return res.status(status).set(
|
|
22
|
+
'Cache-Control',
|
|
23
|
+
(typeof global.cache_control === 'function' && global.cache_control(status))
|
|
24
|
+
|| defaultCache,
|
|
25
|
+
);
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
const fallback = (err: any, status = 500) => {
|
|
@@ -32,6 +38,35 @@ export default (req: Request, res: Response) => {
|
|
|
32
38
|
}
|
|
33
39
|
};
|
|
34
40
|
|
|
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) => {
|
|
60
|
+
if (err) {
|
|
61
|
+
logger.error(err);
|
|
62
|
+
fallback(err);
|
|
63
|
+
} else {
|
|
64
|
+
(res.WRITE as Response['write'])(data);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
|
|
35
70
|
/*
|
|
36
71
|
https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
|
|
37
72
|
import { handler as ssrHandler } from '../dist/server/entry.mjs';
|
|
@@ -8,8 +8,8 @@ import serveStorefront from './firebase/serve-storefront';
|
|
|
8
8
|
const { httpsFunctionOptions } = config.get();
|
|
9
9
|
|
|
10
10
|
export const ssr = onRequest({
|
|
11
|
-
timeoutSeconds:
|
|
12
|
-
memory: '
|
|
11
|
+
timeoutSeconds: 15,
|
|
12
|
+
memory: '256MiB',
|
|
13
13
|
// minInstances: 1,
|
|
14
14
|
...httpsFunctionOptions,
|
|
15
15
|
}, (req, res) => {
|