Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

Commit

Permalink
improvment: upload image to CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
irfan-maulana-tkp authored and josteph committed Aug 2, 2020
1 parent cda8ebc commit bc56838
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
39 changes: 19 additions & 20 deletions server/data/products.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
const { API_URL } = process.env;
const IMAGE_URL = API_URL.replace('/api', '/images');
const IMAGE_CDN_URL = 'https://res.cloudinary.com/irfan-maulana-tkpd/image/upload';

const createProduct = (id, name, price, review, rating, imageIndex) => {
const createProduct = (id, name, price, review, rating, imageUrl) => {
return {
id,
name,
image: `${IMAGE_URL}/product-${imageIndex}.jpg`,
image: `${IMAGE_CDN_URL}${imageUrl}`,
price,
review,
rating,
};
};

export default [
createProduct('product-1', 'Prouduct 1', 'Rp. 123.000', 5, 5, 1),
createProduct('product-2', 'Prouduct 2', 'Rp. 242.000', 5, 5, 2),
createProduct('product-3', 'Prouduct 3', 'Rp. 976.000', 5, 5, 3),
createProduct('product-4', 'Prouduct 4', 'Rp. 567.000', 5, 5, 4),
createProduct('product-5', 'Prouduct 5', 'Rp. 32.000', 5, 5, 5),
createProduct('product-6', 'Prouduct 6', 'Rp. 12.000', 5, 5, 6),
createProduct('product-7', 'Prouduct 7', 'Rp. 1.000', 5, 5, 7),
createProduct('product-8', 'Prouduct 8', 'Rp. 32.000', 5, 5, 8),
createProduct('product-9', 'Prouduct 9', 'Rp. 32.000', 5, 5, 9),
createProduct('product-10', 'Prouduct 10', 'Rp. 4.000', 5, 5, 10),
createProduct('product-11', 'Prouduct 11', 'Rp. 564.000', 5, 5, 11),
createProduct('product-12', 'Prouduct 12', 'Rp. 5.000', 5, 5, 12),
createProduct('product-13', 'Prouduct 12', 'Rp. 878.000', 5, 5, 13),
createProduct('product-14', 'Prouduct 14', 'Rp. 912.000', 5, 5, 14),
createProduct('product-15', 'Prouduct 15', 'Rp. 156.000', 5, 5, 15),
createProduct('product-16', 'Prouduct 16', 'Rp. 176.000', 5, 5, 16),
createProduct('product-1', 'Prouduct 1', 'Rp. 123.000', 5, 5, '/v1595999139/product-1_iadqf4.jpg'),
createProduct('product-2', 'Prouduct 2', 'Rp. 242.000', 5, 5, '/v1595999139/product-2_mtdzun.jpg'),
createProduct('product-3', 'Prouduct 3', 'Rp. 976.000', 5, 5, '/v1595999139/product-3_onudly.jpg'),
createProduct('product-4', 'Prouduct 4', 'Rp. 567.000', 5, 5, '/v1595999139/product-4_cvpqz5.jpg'),
createProduct('product-5', 'Prouduct 5', 'Rp. 32.000', 5, 5, '/v1595856357/product-5_xcxn7d.jpg'),
createProduct('product-6', 'Prouduct 6', 'Rp. 12.000', 5, 5, '/v1595856358/product-6_olcdsk.jpg'),
createProduct('product-7', 'Prouduct 7', 'Rp. 1.000', 5, 5, '/v1595856463/product-7_lwfhun.jpg'),
createProduct('product-8', 'Prouduct 8', 'Rp. 32.000', 5, 5, '/v1595856355/product-8_qd0u0t.jpg'),
createProduct('product-9', 'Prouduct 9', 'Rp. 32.000', 5, 5, '/v1595856356/product-9_kcj58m.jpg'),
createProduct('product-10', 'Prouduct 10', 'Rp. 4.000', 5, 5, '/v1595856357/product-10_pl8tka.jpg'),
createProduct('product-11', 'Prouduct 11', 'Rp. 564.000', 5, 5, '/v1595856366/product-11_qwknkh.jpg'),
createProduct('product-12', 'Prouduct 12', 'Rp. 5.000', 5, 5, '/v1595856364/product-12_mcpldu.jpg'),
createProduct('product-13', 'Prouduct 12', 'Rp. 878.000', 5, 5, '/v1595856366/product-13_i3zqg3.jpg'),
createProduct('product-14', 'Prouduct 14', 'Rp. 912.000', 5, 5, '/v1595856363/product-14_pr37lm.jpg'),
createProduct('product-15', 'Prouduct 15', 'Rp. 156.000', 5, 5, '/v1595856361/product-15_ejitc4.jpg'),
createProduct('product-16', 'Prouduct 16', 'Rp. 176.000', 5, 5, '/v1595856360/product-16_nqd073.jpg'),
];
6 changes: 1 addition & 5 deletions utils/html/preconnect-tags.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import createPreconnectTag from './create-preconnect-tag';

const preconnectSources = [
'https://googleads.g.doubleclick.net',
'https://www.google-analytics.com',
'https://www.googleadservices.com',
'https://www.googletagmanager.com',
'https://connect.facebook.net',
'https://res.cloudinary.com',
];

const preconnectTags = preconnectSources.map(createPreconnectTag).join('\n');
Expand Down

0 comments on commit bc56838

Please sign in to comment.