Skip to content

Commit ef39791

Browse files
authored
Admin API: Include current traffic distribution (#31)
* return versions when listing frontends for a project and when listing version for a given mfe * increment version
1 parent bbd08fc commit ef39791

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

docs/API.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ Example Response:
9191
"microFrontends": [
9292
{
9393
"name": "my-project/catalog-123",
94-
"id": "27a7928f-9ae2-4f6a-bc51-8478c91f7517"
94+
"id": "27a7928f-9ae2-4f6a-bc51-8478c91f7517",
95+
"activeVersions": [
96+
{
97+
"traffic": 100,
98+
"version": "2.0.0"
99+
}
100+
]
95101
}
96102
]
97103
}
@@ -175,6 +181,12 @@ Example Response:
175181
{
176182
"projectId": "ccc1673f-02aa-48cd-b82a-a7911e7150ab",
177183
"microFrontendId": "27a7928f-9ae2-4f6a-bc51-8478c91f7517",
184+
"activeVersions": [
185+
{
186+
"traffic": 100,
187+
"version": "2.0.0"
188+
}
189+
],
178190
"versions": [
179191
{
180192
"url": "https://static.example.com/my-account-1.0.0.js",

infrastructure/lambda/adminApi/app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export const getFrontendsApi = middy().handler(async (event, context) => {
141141
let resultItem = {
142142
name: `${project.name}/${mfe.name}`,
143143
id: mfe.microFrontendId,
144+
activeVersions: mfe.activeVersions,
144145
};
145146
if (mfe.deleted) resultItem.deleted = mfe.deleted;
146147
return resultItem;
@@ -175,6 +176,7 @@ export const getFrontendVersionsApi = middy().handler(
175176

176177
result.name = `${project.name}/${mfe.name}`;
177178
result.versions = versions.map((v) => v.data);
179+
result.activeVersions = mfe.activeVersions;
178180

179181
return {
180182
statusCode: 200,

template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AWSTemplateFormatVersion: "2010-09-09"
22
Transform: AWS::Serverless-2016-10-31
3-
Description: Frontend Service Discovery on AWS (uksb-1tthgi8k7) (version:v1.2)
3+
Description: Frontend Service Discovery on AWS (uksb-1tthgi8k7) (version:v1.3)
44

55
Globals:
66
Function:
@@ -68,7 +68,7 @@ Conditions:
6868
Mappings:
6969
Solution:
7070
Constants:
71-
Version: '1.2'
71+
Version: '1.3'
7272

7373
Resources:
7474
ProjectStore:

tests/adminApi.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ describe("Admin Api", () => {
234234
{
235235
name: `${projectStub.name}/${mfeStub.name}`,
236236
id: mfeStub.microFrontendId,
237+
activeVersions: mfeStub.activeVersions,
237238
},
238239
],
239240
});
@@ -271,6 +272,7 @@ describe("Admin Api", () => {
271272
{
272273
name: `${projectStub.name}/${mfeStub.name}`,
273274
id: mfeStub.microFrontendId,
275+
activeVersions: mfeStub.activeVersions,
274276
deleted: true,
275277
},
276278
],
@@ -320,6 +322,7 @@ describe("Admin Api", () => {
320322
projectId: projectStub.projectId,
321323
name: `${projectStub.name}/${mfeStub.name}`,
322324
microFrontendId: event.pathParameters.microFrontendId,
325+
activeVersions: mfeStub.activeVersions,
323326
versions: versionsStub.Items.map((v) => v.data),
324327
});
325328
expect(result.statusCode).toBe(200);

tests/integration.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ describe("getting a list of frontends for a project", () => {
338338
{
339339
name: `${project.name}/${mfe.name}`,
340340
id: mfe.id,
341+
activeVersions: [
342+
{
343+
version: mfeVersion1.metadata.version,
344+
traffic: 100,
345+
},
346+
],
341347
},
342348
],
343349
};
@@ -385,6 +391,12 @@ describe("getting an mfe with versions", () => {
385391
projectId: project.id,
386392
microFrontendId: mfe.id,
387393
name: `${project.name}/${mfe.name}`,
394+
activeVersions: [
395+
{
396+
version: mfeVersion1.metadata.version,
397+
traffic: 100,
398+
},
399+
],
388400
versions: [mfeVersion1, mfeVersion2],
389401
};
390402
expect(response.body).toStrictEqual(expected);

0 commit comments

Comments
 (0)