cloudcommerce 0.0.29 → 0.0.32
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 +27 -0
- package/CONTRIBUTING.md +18 -0
- package/action.yml +16 -3
- package/package.json +6 -5
- package/packages/api/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/cli/lib/index.js +5 -2
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/index.ts +8 -5
- package/packages/firebase/lib/env.js +19 -0
- package/packages/firebase/lib/env.js.map +1 -0
- package/packages/firebase/lib/index.js +8 -2
- package/packages/firebase/lib/index.js.map +1 -1
- package/packages/firebase/lib/methods/check-store-events.js +21 -0
- package/packages/firebase/lib/methods/check-store-events.js.map +1 -0
- package/packages/firebase/package.json +1 -1
- package/packages/firebase/src/env.ts +30 -0
- package/packages/firebase/src/index.ts +9 -3
- package/packages/firebase/src/methods/check-store-events.ts +20 -0
- package/packages/storefront/package.json +2 -2
- package/pnpm-lock.yaml +222 -524
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
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.32](https://github.com/ecomplus/cloud-commerce/compare/v0.0.31...v0.0.32) (2022-07-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **firebase:** Get `process.env` on function handler only ([2095621](https://github.com/ecomplus/cloud-commerce/commit/209562152d31a4f31104502897af2f2330c3330f))
|
|
11
|
+
|
|
12
|
+
### [0.0.31](https://github.com/ecomplus/cloud-commerce/compare/v0.0.30...v0.0.31) (2022-07-20)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* GH Action must get credentials from inputs (`secrets` unrecognized) ([482f82b](https://github.com/ecomplus/cloud-commerce/commit/482f82bc4ff3ddc73445b4ffbbf5bf9655cf7de2))
|
|
18
|
+
|
|
19
|
+
### [0.0.30](https://github.com/ecomplus/cloud-commerce/compare/v0.0.29...v0.0.30) (2022-07-20)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **firebase:** Start listing stor eevents (orders, carts, products) with new cron function ([2eb0616](https://github.com/ecomplus/cloud-commerce/commit/2eb06168b03e7cd751c58001cf36c8253da040d7))
|
|
25
|
+
* GH Action setup functions .env with repo secrets ([98bf2a2](https://github.com/ecomplus/cloud-commerce/commit/98bf2a2ba25edd45da32555fa6e18fab3b459be8))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **cli:** Do not change `config.json with `--no-commit` option ([f94ca57](https://github.com/ecomplus/cloud-commerce/commit/f94ca5740d16412a0c07537d512632f5d12a5904))
|
|
31
|
+
|
|
5
32
|
### [0.0.29](https://github.com/ecomplus/cloud-commerce/compare/v0.0.28...v0.0.29) (2022-07-17)
|
|
6
33
|
|
|
7
34
|
### [0.0.28](https://github.com/ecomplus/cloud-commerce/compare/v0.0.27...v0.0.28) (2022-07-17)
|
package/CONTRIBUTING.md
CHANGED
|
@@ -12,6 +12,7 @@ Clone this repo to your local machine and install the dependencies:
|
|
|
12
12
|
|
|
13
13
|
```console
|
|
14
14
|
git clone --recurse-submodules git@github.com:ecomplus/cloud-commerce.git
|
|
15
|
+
cd cloud-commerce
|
|
15
16
|
pnpm install
|
|
16
17
|
```
|
|
17
18
|
|
|
@@ -43,3 +44,20 @@ If you want to deploy to a new Firebase project (needed for larger changes):
|
|
|
43
44
|
4. Go to `/store` folder and edit `.firebaserc` setting your project ID (don't commit this file);
|
|
44
45
|
|
|
45
46
|
5. Deploy with `firebase login && npm run deploy`;
|
|
47
|
+
|
|
48
|
+
## Development
|
|
49
|
+
|
|
50
|
+
To emulate Firebase and serve all starter Store services locally, run the following commands on the monorepo root:
|
|
51
|
+
|
|
52
|
+
```console
|
|
53
|
+
pnpm run setup
|
|
54
|
+
pnpm serve
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`run setup` is only needed for the first time, it'll get your store credentials and put them in `functions/.env`.
|
|
58
|
+
|
|
59
|
+
To run tests for all packages:
|
|
60
|
+
|
|
61
|
+
```console
|
|
62
|
+
pnpm test
|
|
63
|
+
```
|
package/action.yml
CHANGED
|
@@ -8,6 +8,12 @@ inputs:
|
|
|
8
8
|
firebase-service-account:
|
|
9
9
|
description: 'Firebase service account JSON'
|
|
10
10
|
required: true
|
|
11
|
+
ecom-authentication-id:
|
|
12
|
+
description: 'E-Com Plus store authentication ID'
|
|
13
|
+
required: true
|
|
14
|
+
ecom-api-key:
|
|
15
|
+
description: 'E-Com Plus store API key'
|
|
16
|
+
required: true
|
|
11
17
|
|
|
12
18
|
outputs: {}
|
|
13
19
|
|
|
@@ -37,11 +43,18 @@ runs:
|
|
|
37
43
|
name: Deploy to Firebase live
|
|
38
44
|
shell: bash
|
|
39
45
|
env:
|
|
46
|
+
GITHUB_TOKEN: ${{ inputs.github-token }}
|
|
40
47
|
FIREBASE_SERVICE_ACCOUNT: ${{ inputs.firebase-service-account }}
|
|
48
|
+
ECOM_AUTHENTICATION_ID: ${{ inputs.ecom-authentication-id }}
|
|
49
|
+
ECOM_API_KEY: ${{ inputs.ecom-api-key }}
|
|
41
50
|
run: |
|
|
42
|
-
export GAC_FILENAME=".gac-$RANDOM.json"
|
|
43
|
-
echo $FIREBASE_SERVICE_ACCOUNT > $GAC_FILENAME
|
|
44
|
-
|
|
51
|
+
export GAC_FILENAME=".gac-$RANDOM.json"
|
|
52
|
+
echo $FIREBASE_SERVICE_ACCOUNT > $GAC_FILENAME
|
|
53
|
+
printf "ECOM_AUTHENTICATION_ID=$ECOM_AUTHENTICATION_ID
|
|
54
|
+
ECOM_API_KEY=$ECOM_API_KEY
|
|
55
|
+
GITHUB_TOKEN=$GITHUB_TOKEN
|
|
56
|
+
" > functions/.env
|
|
57
|
+
GOOGLE_APPLICATION_CREDENTIALS=$GAC_FILENAME npm run deploy
|
|
45
58
|
|
|
46
59
|
- if: github.event_name == 'pull_request'
|
|
47
60
|
name: Deploy Firebase Hosting PR preview
|
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.32",
|
|
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>",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"@commitlint/config-conventional": "^17.0.3",
|
|
21
21
|
"@commitlint/rules": "^17.0.0",
|
|
22
22
|
"@types/node": "^18.0.5",
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^5.30.
|
|
24
|
-
"@typescript-eslint/parser": "^5.30.
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
24
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
25
25
|
"esbuild": "^0.14.49",
|
|
26
26
|
"eslint": "^8.20.0",
|
|
27
27
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
28
28
|
"eslint-plugin-import": "^2.26.0",
|
|
29
29
|
"eslint-plugin-vue": "^9.2.0",
|
|
30
30
|
"husky": "^8.0.1",
|
|
31
|
-
"node-fetch": "^3.2.
|
|
31
|
+
"node-fetch": "^3.2.9",
|
|
32
32
|
"standard-version": "^9.5.0",
|
|
33
33
|
"turbo": "^1.3.1",
|
|
34
34
|
"typescript": "^4.7.4",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"store:run": "pnpm build && npm --prefix \"store\" run",
|
|
46
46
|
"start": "pnpm store:run start",
|
|
47
47
|
"serve": "pnpm store:run serve",
|
|
48
|
-
"deploy": "pnpm store:run deploy"
|
|
48
|
+
"deploy": "pnpm store:run deploy",
|
|
49
|
+
"setup": "pnpm store:run setup:quiet"
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -62,12 +62,15 @@ export default async () => {
|
|
|
62
62
|
}
|
|
63
63
|
if (argv._.includes('setup')) {
|
|
64
64
|
const { storeId, authenticationId, apiKey } = await login();
|
|
65
|
-
fs.writeFileSync(path.join(pwd, 'functions', '
|
|
66
|
-
|
|
65
|
+
fs.writeFileSync(path.join(pwd, 'functions', '.env'), `ECOM_AUTHENTICATION_ID=${authenticationId}
|
|
66
|
+
ECOM_API_KEY=${apiKey}
|
|
67
|
+
ECOM_STORE_ID=${storeId}
|
|
68
|
+
`);
|
|
67
69
|
if (argv.deploy !== false) {
|
|
68
70
|
await $firebase('deploy');
|
|
69
71
|
}
|
|
70
72
|
if (argv.commit !== false) {
|
|
73
|
+
fs.writeFileSync(path.join(pwd, 'functions', 'config.json'), JSON.stringify({ storeId }, null, 2));
|
|
71
74
|
try {
|
|
72
75
|
await $`git add .firebaserc functions/config.json`;
|
|
73
76
|
await $`git commit -m "Setup store [skip ci]"`;
|
|
@@ -78,18 +78,21 @@ export default async () => {
|
|
|
78
78
|
|
|
79
79
|
if (argv._.includes('setup')) {
|
|
80
80
|
const { storeId, authenticationId, apiKey } = await login();
|
|
81
|
-
fs.writeFileSync(
|
|
82
|
-
path.join(pwd, 'functions', 'config.json'),
|
|
83
|
-
JSON.stringify({ storeId }, null, 2),
|
|
84
|
-
);
|
|
85
81
|
fs.writeFileSync(
|
|
86
82
|
path.join(pwd, 'functions', '.env'),
|
|
87
|
-
`ECOM_AUTHENTICATION_ID=${authenticationId}
|
|
83
|
+
`ECOM_AUTHENTICATION_ID=${authenticationId}
|
|
84
|
+
ECOM_API_KEY=${apiKey}
|
|
85
|
+
ECOM_STORE_ID=${storeId}
|
|
86
|
+
`,
|
|
88
87
|
);
|
|
89
88
|
if (argv.deploy !== false) {
|
|
90
89
|
await $firebase('deploy');
|
|
91
90
|
}
|
|
92
91
|
if (argv.commit !== false) {
|
|
92
|
+
fs.writeFileSync(
|
|
93
|
+
path.join(pwd, 'functions', 'config.json'),
|
|
94
|
+
JSON.stringify({ storeId }, null, 2),
|
|
95
|
+
);
|
|
93
96
|
try {
|
|
94
97
|
await $`git add .firebaserc functions/config.json`;
|
|
95
98
|
await $`git commit -m "Setup store [skip ci]"`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
const { ECOM_AUTHENTICATION_ID, ECOM_API_KEY, GITHUB_TOKEN } = process.env;
|
|
3
|
+
if (!ECOM_AUTHENTICATION_ID) {
|
|
4
|
+
throw new Error('ECOM_AUTHENTICATION_ID is not set');
|
|
5
|
+
}
|
|
6
|
+
if (!ECOM_API_KEY) {
|
|
7
|
+
throw new Error('ECOM_API_KEY is not set');
|
|
8
|
+
}
|
|
9
|
+
const authenticationId = ECOM_AUTHENTICATION_ID;
|
|
10
|
+
const apiKey = ECOM_API_KEY;
|
|
11
|
+
const githubToken = GITHUB_TOKEN;
|
|
12
|
+
const env = {
|
|
13
|
+
authenticationId,
|
|
14
|
+
apiKey,
|
|
15
|
+
githubToken,
|
|
16
|
+
};
|
|
17
|
+
return env;
|
|
18
|
+
};
|
|
19
|
+
// # sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAMA,eAAe,GAAG,EAAE;IAClB,MAAM,EACJ,sBAAsB,EACtB,YAAY,EACZ,YAAY,GACb,GAAG,OAAO,CAAC,GAAG,CAAC;IAChB,IAAI,CAAC,sBAAsB,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IACD,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IACD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC;IAC5B,MAAM,WAAW,GAAG,YAAY,CAAC;IACjC,MAAM,GAAG,GAAQ;QACf,gBAAgB;QAChB,MAAM;QACN,WAAW;KACZ,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import 'source-map-support/register.js';
|
|
2
|
-
import { logger } from 'firebase-functions';
|
|
2
|
+
import { pubsub, logger } from 'firebase-functions';
|
|
3
3
|
// eslint-disable-next-line import/no-unresolved
|
|
4
4
|
import { onRequest } from 'firebase-functions/v2/https';
|
|
5
5
|
import config from './config.js';
|
|
6
|
+
import checkStoreEvents from './methods/check-store-events.js';
|
|
6
7
|
|
|
8
|
+
const processId = String(Date.now());
|
|
7
9
|
const options = {
|
|
8
10
|
region: process.env.DEPLOY_REGION || 'us-east1',
|
|
9
11
|
};
|
|
10
|
-
const processId = String(Date.now());
|
|
11
12
|
|
|
12
13
|
export const z = onRequest(options, ({ url }, response) => {
|
|
14
|
+
process.env.ECOM_API_KEY = '***';
|
|
13
15
|
if (url === '/hello') {
|
|
14
16
|
logger.info('Hello logs!', {
|
|
15
17
|
structuredData: true,
|
|
@@ -29,4 +31,8 @@ export const z = onRequest(options, ({ url }, response) => {
|
|
|
29
31
|
export const ssr = onRequest(options, (request, response) => {
|
|
30
32
|
response.send('<h1>Hello SSR!</h1>');
|
|
31
33
|
});
|
|
34
|
+
|
|
35
|
+
export const cronStoreEvents = pubsub.schedule('* * * * *').onRun(() => {
|
|
36
|
+
return checkStoreEvents();
|
|
37
|
+
});
|
|
32
38
|
// # sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAE5D,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AAErC,MAAM,OAAO,GAAG;IACd,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;CAChD,CAAC;AAEF,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE;IACxD,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;IACjC,IAAI,GAAG,KAAK,QAAQ,EAAE;QACpB,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE;YACzB,cAAc,EAAE,IAAI;SACrB,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO;KACR;IACD,IAAI,GAAG,KAAK,MAAM,EAAE;QAClB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,OAAO;KACR;IACD,QAAQ,CAAC,IAAI,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE;KACrB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC1D,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;IACrE,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { logger } from 'firebase-functions';
|
|
2
|
+
import api from '@cloudcommerce/api';
|
|
3
|
+
import getEnv from '../env.js';
|
|
4
|
+
|
|
5
|
+
export default async () => {
|
|
6
|
+
const { authenticationId, apiKey } = getEnv();
|
|
7
|
+
[
|
|
8
|
+
'orders',
|
|
9
|
+
'products',
|
|
10
|
+
'carts',
|
|
11
|
+
].forEach(async (resource) => {
|
|
12
|
+
const { data: { result } } = await api({
|
|
13
|
+
authenticationId,
|
|
14
|
+
apiKey,
|
|
15
|
+
endpoint: `events/${resource}`,
|
|
16
|
+
});
|
|
17
|
+
logger.info(`${resource} events: `, result);
|
|
18
|
+
});
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
// # sourceMappingURL=check-store-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-store-events.js","sourceRoot":"","sources":["../../src/methods/check-store-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,eAAe,KAAK,IAAI,EAAE;IACxB,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C;QACE,QAAQ;QACR,UAAU;QACV,OAAO;KACR,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC3B,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,GAAG,CAAC;YACrC,gBAAgB;YAChB,MAAM;YACN,QAAQ,EAAE,UAAU,QAAoB,EAAE;SAC3C,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,WAAW,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type Env = {
|
|
2
|
+
authenticationId: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
githubToken?: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
const {
|
|
9
|
+
ECOM_AUTHENTICATION_ID,
|
|
10
|
+
ECOM_API_KEY,
|
|
11
|
+
GITHUB_TOKEN,
|
|
12
|
+
} = process.env;
|
|
13
|
+
if (!ECOM_AUTHENTICATION_ID) {
|
|
14
|
+
throw new Error('ECOM_AUTHENTICATION_ID is not set');
|
|
15
|
+
}
|
|
16
|
+
if (!ECOM_API_KEY) {
|
|
17
|
+
throw new Error('ECOM_API_KEY is not set');
|
|
18
|
+
}
|
|
19
|
+
const authenticationId = ECOM_AUTHENTICATION_ID;
|
|
20
|
+
const apiKey = ECOM_API_KEY;
|
|
21
|
+
const githubToken = GITHUB_TOKEN;
|
|
22
|
+
const env: Env = {
|
|
23
|
+
authenticationId,
|
|
24
|
+
apiKey,
|
|
25
|
+
githubToken,
|
|
26
|
+
};
|
|
27
|
+
return env;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type { Env };
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import 'source-map-support/register.js';
|
|
2
|
-
import { logger } from 'firebase-functions';
|
|
2
|
+
import { pubsub, logger } from 'firebase-functions';
|
|
3
3
|
// eslint-disable-next-line import/no-unresolved
|
|
4
4
|
import { onRequest } from 'firebase-functions/v2/https';
|
|
5
5
|
import config from './config';
|
|
6
|
+
import checkStoreEvents from './methods/check-store-events';
|
|
7
|
+
|
|
8
|
+
const processId = String(Date.now());
|
|
6
9
|
|
|
7
10
|
const options = {
|
|
8
11
|
region: process.env.DEPLOY_REGION || 'us-east1',
|
|
9
12
|
};
|
|
10
13
|
|
|
11
|
-
const processId = String(Date.now());
|
|
12
|
-
|
|
13
14
|
export const z = onRequest(options, ({ url }, response) => {
|
|
15
|
+
process.env.ECOM_API_KEY = '***';
|
|
14
16
|
if (url === '/hello') {
|
|
15
17
|
logger.info('Hello logs!', {
|
|
16
18
|
structuredData: true,
|
|
@@ -30,3 +32,7 @@ export const z = onRequest(options, ({ url }, response) => {
|
|
|
30
32
|
export const ssr = onRequest(options, (request, response) => {
|
|
31
33
|
response.send('<h1>Hello SSR!</h1>');
|
|
32
34
|
});
|
|
35
|
+
|
|
36
|
+
export const cronStoreEvents = pubsub.schedule('* * * * *').onRun(() => {
|
|
37
|
+
return checkStoreEvents();
|
|
38
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { logger } from 'firebase-functions';
|
|
2
|
+
import api from '@cloudcommerce/api';
|
|
3
|
+
import getEnv from '../env';
|
|
4
|
+
|
|
5
|
+
export default async () => {
|
|
6
|
+
const { authenticationId, apiKey } = getEnv();
|
|
7
|
+
[
|
|
8
|
+
'orders',
|
|
9
|
+
'products',
|
|
10
|
+
'carts',
|
|
11
|
+
].forEach(async (resource) => {
|
|
12
|
+
const { data: { result } } = await api({
|
|
13
|
+
authenticationId,
|
|
14
|
+
apiKey,
|
|
15
|
+
endpoint: `events/${resource as 'orders'}`,
|
|
16
|
+
});
|
|
17
|
+
logger.info(`${resource} events: `, result);
|
|
18
|
+
});
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/storefront",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.32",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce storefront with Astro",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@cloudcommerce/api": "workspace:*",
|
|
23
|
-
"astro": "1.0.0-beta.
|
|
23
|
+
"astro": "1.0.0-beta.72"
|
|
24
24
|
}
|
|
25
25
|
}
|