forked from aws-samples/retail-demo-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayer0.config.js
113 lines (108 loc) · 3.01 KB
/
layer0.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
require("dotenv").config();
const removeProtocol = (domain) => {
try {
return domain.replace(/https?:\/\//i, "");
} catch (e) {
console.error("[layer0.config.js] Invalid domain: ", domain);
throw new Error(e.message);
}
};
const buildServiceDomain = (domain, port) => {
let serviceDomain = removeProtocol(domain);
if (port) {
serviceDomain += `:${port}`;
}
return serviceDomain;
};
// Build upstream endpoints
// For local dev, this should be `localhost`
// When deployed, each service should have its domain defined to the
// ELB domain provided by AWS
const productsService = buildServiceDomain(
process.env.VITE_PRODUCTS_SERVICE_DOMAIN,
process.env.VITE_PRODUCTS_SERVICE_PORT
);
const recommendationsService = buildServiceDomain(
process.env.VITE_RECOMMENDATIONS_SERVICE_DOMAIN,
process.env.VITE_RECOMMENDATIONS_SERVICE_PORT
);
const cartsService = buildServiceDomain(
process.env.VITE_CARTS_SERVICE_DOMAIN,
process.env.VITE_CARTS_SERVICE_PORT
);
const usersService = buildServiceDomain(
process.env.VITE_USERS_SERVICE_DOMAIN,
process.env.VITE_USERS_SERVICE_PORT
);
const ordersService = buildServiceDomain(
process.env.VITE_ORDERS_SERVICE_DOMAIN,
process.env.VITE_ORDERS_SERVICE_PORT
);
const searchService = buildServiceDomain(
process.env.VITE_SEARCH_SERVICE_DOMAIN,
process.env.VITE_SEARCH_SERVICE_PORT
);
const videosService = buildServiceDomain(
process.env.VITE_VIDEOS_SERVICE_DOMAIN,
process.env.VITE_VIDEOS_SERVICE_PORT
);
const locationService = buildServiceDomain(
process.env.VITE_LOCATION_SERVICE_DOMAIN,
process.env.VITE_LOCATION_SERVICE_PORT
);
const imageService = process.env.AWS_IMAGE_SERVICE_DOMAIN;
module.exports = {
routes: "./layer0/routes.js",
includeFiles: {
".env": true,
},
backends: {
"products-service": {
domainOrIp: productsService,
hostHeader: productsService,
disableCheckCert: true,
},
"recommendations-service": {
domainOrIp: recommendationsService,
hostHeader: recommendationsService,
disableCheckCert: true,
},
"carts-service": {
domainOrIp: cartsService,
hostHeader: cartsService,
disableCheckCert: true,
},
"users-service": {
domainOrIp: usersService,
hostHeader: usersService,
disableCheckCert: false,
},
"search-service": {
domainOrIp: searchService,
hostHeader: searchService,
disableCheckCert: false,
},
"orders-service": {
domainOrIp: ordersService,
hostHeader: ordersService,
disableCheckCert: false,
},
"videos-service": {
domainOrIp: videosService,
hostHeader: videosService,
disableCheckCert: false,
},
"location-service": {
domainOrIp: locationService,
hostHeader: locationService,
disableCheckCert: false,
},
"images": {
domainOrIp: imageService,
hostHeader: imageService,
disableCheckCert: false,
},
},
};