Skip to content

Commit 9a1199d

Browse files
add calling image provider by image name
1 parent 1eae415 commit 9a1199d

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ build:
100100
build-and-push:
101101
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(DOCKER_COMPOSE_BUILD_ARGS) --push
102102

103+
# Use to build and push a single service component
104+
# Example: make build-and-push-service service=frontend
105+
.PHONY: build-and-push-service
106+
build-and-push-service:
107+
# work with `service` or `SERVICE` as input
108+
ifdef SERVICE
109+
service := $(SERVICE)
110+
endif
111+
112+
ifdef service
113+
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(DOCKER_COMPOSE_BUILD_ARGS) --push $(service)
114+
else
115+
@echo "Please provide a service name using `service=[service name]` or `SERVICE=[service name]`"
116+
endif
117+
103118
# Create multiplatform builder for buildx
104119
.PHONY: create-multiplatform-builder
105120
create-multiplatform-builder:

src/frontend/components/ProductCard/ProductCard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const ProductCard = ({
2121
product: {
2222
id,
2323
name,
24+
picture,
2425
priceUsd = {
2526
currencyCode: 'USD',
2627
units: 0,
@@ -41,7 +42,8 @@ const ProductCard = ({
4142
method: 'GET',
4243
headers: headers,
4344
};
44-
const image_url = `/api/images/${id}`;
45+
console.log("aaaa" + picture)
46+
const image_url = `/api/images/${picture}`;
4547
const requestInfo = new Request(image_url, requestInit);
4648
getImageWithHeaders(requestInfo).then(blob => {
4749
setImageSrc(URL.createObjectURL(blob));
Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
11
import type { NextApiRequest, NextApiResponse } from 'next';
22

3-
const idTranslation: Record<string, string> = {
4-
'OLJCESPC7Z': 'NationalParkFoundationExplorascope.jpg',
5-
'66VCHSJNUP': 'StarsenseExplorer.jpg',
6-
'1YMWWN1N4O': 'EclipsmartTravelRefractorTelescope.jpg',
7-
'L9ECAV7KIM': 'LensCleaningKit.jpg',
8-
'2ZYFJ3GM2N': 'RoofBinoculars.jpg',
9-
'0PUK6V6EV0': 'SolarSystemColorImager.jpg',
10-
'LS4PSXUNUM': 'RedFlashlight.jpg',
11-
'9SIQT8TOJO': 'OpticalTubeAssembly.jpg',
12-
'6E92ZMYYFZ': 'SolarFilter.jpg',
13-
'HQTGWGPNH4': 'TheCometBook.jpg',
14-
};
15-
163
const SCREEN = '860x600';
174

185
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
196
try {
20-
const { id } = req.query;
7+
const { image } = req.query;
218

22-
if (typeof id !== 'string') {
9+
if (typeof image !== 'string') {
2310
return res.status(400).send('Missing "productId"');
2411
}
2512

2613
let url;
2714

2815
if (process.env.LAMBDA_URL === undefined) {
29-
const image = idTranslation[id];
30-
31-
if (image === undefined) {
32-
return res.status(404).send(`Image for product [${id}] not found`);
33-
}
34-
3516
url = `http://image-provider:8081/products/${image}`;
3617

3718
console.log(`Fetching image from [${url}]`);
@@ -48,7 +29,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
4829
}
4930

5031
const presignUrl = new URL(`${process.env.LAMBDA_URL}/images`);
51-
presignUrl.searchParams.set('productId', id);
32+
presignUrl.searchParams.set('productImage', image);
5233
presignUrl.searchParams.set('screen', SCREEN);
5334

5435
const headers = new Headers();

0 commit comments

Comments
 (0)