Skip to content

Commit f0850d5

Browse files
authored
Merge branch 'main' into fix-r2-bindings
2 parents 963febf + 375def5 commit f0850d5

35 files changed

+2037
-378
lines changed

.eslintrc.cjs

+7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ module.exports = {
4646
// parameters is definitely desirable
4747
'no-param-reassign': 'off',
4848

49+
'import/no-extraneous-dependencies': [
50+
'error',
51+
{
52+
devDependencies: true,
53+
},
54+
],
55+
4956
// Allow while (true) infinite loops
5057
// 'no-constant-condition': ['error', { checkLoops: false }],
5158

.vscode/launch.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Debug Current Mocha Test",
8+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
9+
"args": [
10+
"--timeout", "999999",
11+
"--colors",
12+
"--no-timeouts",
13+
"${file}"
14+
],
15+
"console": "integratedTerminal",
16+
"internalConsoleOptions": "neverOpen",
17+
"skipFiles": ["<node_internals>/**"],
18+
"cwd": "${workspaceFolder}"
19+
}
20+
]
21+
}

.vscode/settings.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": "explicit",
4+
"source.fixAll.stylelint": "explicit"
5+
},
6+
"eslint.enable": true,
7+
"prettier.enable": true,
8+
"eslint.validate": ["javascript"],
9+
"stylelint.enable": true,
10+
"[css]": {
11+
"editor.defaultFormatter": "stylelint.vscode-stylelint"
12+
},
13+
"[json]": {
14+
"editor.defaultFormatter": "esbenp.prettier-vscode"
15+
},
16+
"liveServer.settings.port": 5501,
17+
}

CHANGELOG.md

+36
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
# [1.2.0](https://github.com/adobe-rnd/helix-commerce-api/compare/v1.1.9...v1.2.0) (2024-10-22)
2+
3+
4+
### Bug Fixes
5+
6+
* add ci r2 bindings ([dff1907](https://github.com/adobe-rnd/helix-commerce-api/commit/dff1907971d82879c72d9bdfaccf544f6b2658d4))
7+
* add envs to configs ([b733899](https://github.com/adobe-rnd/helix-commerce-api/commit/b73389958597660dec359349bb257d09632549e0))
8+
* add tests ([28cceb8](https://github.com/adobe-rnd/helix-commerce-api/commit/28cceb847c0d83c31e93fba5c3fbab8314c3afe5))
9+
* cleanup ([a4a3afa](https://github.com/adobe-rnd/helix-commerce-api/commit/a4a3afac3b5124c214d0de4546d94f5ef3988da6))
10+
* disable preview ([dd25a23](https://github.com/adobe-rnd/helix-commerce-api/commit/dd25a23a9ff794ca621d3cde961571b1af9f5837))
11+
* don't default org repo ([21ad084](https://github.com/adobe-rnd/helix-commerce-api/commit/21ad08478f3ee250863b66702f706414ed4cc396))
12+
* encoding ([11bb8bc](https://github.com/adobe-rnd/helix-commerce-api/commit/11bb8bcdc0e5c68826dc8a084ea525c7e9a87ddc))
13+
* more cleanup ([f1c2d27](https://github.com/adobe-rnd/helix-commerce-api/commit/f1c2d27c430b9bb15c54425a87683af7ceac8ff6))
14+
* org not owner ([478bf85](https://github.com/adobe-rnd/helix-commerce-api/commit/478bf85985f0fc81d8ec54a591ece26a099caa04))
15+
* pattern matching ([f58f18e](https://github.com/adobe-rnd/helix-commerce-api/commit/f58f18e89ddc68b6ce7e889761d75d596b1d89e0))
16+
* preview call ([4ba5ea8](https://github.com/adobe-rnd/helix-commerce-api/commit/4ba5ea8a754d19512a82e4462aafa8f07f1ab1f9))
17+
* pull from helix catalog ([918ca03](https://github.com/adobe-rnd/helix-commerce-api/commit/918ca03b432dbc3a2ea6a7a0742ae571aafa1669))
18+
* remove content type and body for 301 ([9280dab](https://github.com/adobe-rnd/helix-commerce-api/commit/9280dabe7594057f16f3d6e572127061700d0d53))
19+
* rename catalog functions ([28e4374](https://github.com/adobe-rnd/helix-commerce-api/commit/28e43745bd016da50f0cf96cb6adca90d721e377))
20+
* return 301 for urlKey lookup ([e0388d5](https://github.com/adobe-rnd/helix-commerce-api/commit/e0388d5f7232a2cc61c6e734dd585b399486376b))
21+
* switch to org--repo tenant ([5957e1a](https://github.com/adobe-rnd/helix-commerce-api/commit/5957e1a1f1374c1cfa52b9848143d50727c4bcdf))
22+
* switch to org/site ([44853a8](https://github.com/adobe-rnd/helix-commerce-api/commit/44853a8229d123b07b924a0a40a661cb8bed2295))
23+
* test and update ([71dc947](https://github.com/adobe-rnd/helix-commerce-api/commit/71dc94731a44a1b1a732be0221324e6e573e02d7))
24+
* tests ([e6fbd50](https://github.com/adobe-rnd/helix-commerce-api/commit/e6fbd50c6eff061f89f054ac68ea35d6b678f534))
25+
* tests ([29a006c](https://github.com/adobe-rnd/helix-commerce-api/commit/29a006ca8e881f5ee67867f7aebd803833451648))
26+
* tweak r2 paths ([c90abd4](https://github.com/adobe-rnd/helix-commerce-api/commit/c90abd415e549f1d43c42a8650e00262d0e6788d))
27+
* urlKey tests ([3a84208](https://github.com/adobe-rnd/helix-commerce-api/commit/3a842085164544f9dcb9ac4e352b0f4a117fa209))
28+
* use env in catalog route ([0959827](https://github.com/adobe-rnd/helix-commerce-api/commit/095982795f6cb0be072b6015f3d64584bacf6e74))
29+
* use sku from path and sanitize ([18d0009](https://github.com/adobe-rnd/helix-commerce-api/commit/18d0009d890331116df29b95cc67189a82f18530))
30+
* validation in put product ([739c10f](https://github.com/adobe-rnd/helix-commerce-api/commit/739c10f68c11cfd12ee1609c8d4995a6a4c441d4))
31+
32+
33+
### Features
34+
35+
* wip catalog service ([069a010](https://github.com/adobe-rnd/helix-commerce-api/commit/069a010e2075d0562244818de9f05dcf53c9fd67))
36+
137
## [1.1.9](https://github.com/adobe-rnd/helix-commerce-api/compare/v1.1.8...v1.1.9) (2024-10-10)
238

339

jsconfig.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES6",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"checkJs": true,
7+
"allowJs": true,
8+
"baseUrl": ".",
9+
"paths": {
10+
"*": ["types/*"],
11+
"@cloudflare/workers-types/*": ["node_modules/@cloudflare/workers-types/*"]
12+
}
13+
},
14+
"include": [
15+
"./**/*.js",
16+
"./src/types.d.ts"
17+
],
18+
"exclude": [
19+
"node_modules",
20+
"dist"
21+
]
22+
}

package-lock.json

+127-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "helix-commerce-api",
3-
"version": "1.1.9",
3+
"version": "1.2.0",
44
"private": true,
55
"description": "API for markup content and a commerce graphql commerce proxy",
66
"main": "src/index.js",
@@ -9,7 +9,7 @@
99
"prepare": "husky",
1010
"build": "node build.js",
1111
"lint": "eslint . --ext js,cjs,mjs",
12-
"test": "c8 mocha -i -g 'Post-Deploy' --spec test/*.test.js",
12+
"test": "c8 --all --include 'src/**/*.js' mocha -i -g 'Post-Deploy' --spec 'test/**/*.test.js'",
1313
"dev": "if test -e .dev.vars; then wrangler dev --; else echo \"Need a .dev.vars files before starting local dev server\"; fi",
1414
"dev:remote": "wrangler dev --remote",
1515
"test-postdeploy": "mocha --spec test/post-deploy.test.js",
@@ -52,12 +52,14 @@
5252
"eslint": "8.57.0",
5353
"eslint-plugin-header": "3.1.1",
5454
"eslint-plugin-import": "2.29.1",
55+
"esmock": "^2.6.9",
5556
"husky": "9.1.4",
5657
"lint-staged": "15.2.9",
5758
"mocha": "10.7.3",
5859
"mocha-multi-reporters": "1.5.1",
5960
"nock": "13.5.4",
6061
"semantic-release": "24.0.0",
62+
"sinon": "^19.0.2",
6163
"wrangler": "3.71.0"
6264
},
6365
"lint-staged": {

src/catalog/fetch.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2024 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
13+
/* eslint-disable no-await-in-loop */
14+
15+
import { errorResponse } from '../utils/http.js';
16+
import { fetchProduct } from '../utils/r2.js';
17+
18+
/**
19+
* Handles a GET request for a product.
20+
* @param {Context} ctx - The context object containing request information and utilities.
21+
* @param {Config} config - The configuration object with application settings.
22+
* @returns {Promise<Response>} - A promise that resolves to the product response.
23+
*/
24+
export async function handleProductFetchRequest(ctx, config) {
25+
try {
26+
const sku = ctx.url.pathname.split('/').pop();
27+
const product = await fetchProduct(ctx, config, sku);
28+
29+
return new Response(JSON.stringify(product), {
30+
headers: { 'Content-Type': 'application/json' },
31+
});
32+
} catch (e) {
33+
if (e.response) {
34+
return e.response;
35+
}
36+
ctx.log.error(e);
37+
return errorResponse(500, 'internal server error');
38+
}
39+
}

0 commit comments

Comments
 (0)