Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ npm start

The list of available APIs can be viewed on localhost:8000/api by default but this can be customised - see later.

A list of all endpoints can be viewed on http://localhost:8000/.
A list of all endpoints can be viewed on the mock server dashboard at http://localhost:8000/.

The project has been set-up with demo endpoints that can be removed or modified as needed.

Expand Down
56 changes: 28 additions & 28 deletions cypress/e2e/server-page-spec.cy.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
describe('Server page contains expected information', () => {
it('passes', () => {
const expectedEndpoints = [
'/api/bikes',
'/api/cats',
'/api/images',
'/api/json',
'/api/lambda',
'/api/markdown',
'/api/posts',
'/api/users',
'/api/videos',
'/api/error',
];
cy.visit('/');
cy.get('h1').contains('Running');
it('passes', () => {
const expectedEndpoints = [
'/api/bikes',
'/api/cats',
'/api/images',
'/api/json',
'/api/lambda',
'/api/markdown',
'/api/posts',
'/api/users',
'/api/videos',
'/api/error',
];
cy.visit('/');
cy.get('[cy-data="server_status"]').contains('Running');

cy.get('h3').contains('Server Address');
cy.get('h3').contains('Server Port');
cy.get('h3').contains('Server URL Prefix');
cy.get('h3').contains('API endpoints');
cy.get('[cy-data="server_address"]').contains('Server Address');
cy.get('[cy-data="server_port"]').contains('Server Port');
cy.get('[cy-data="server_prefix"]').contains('Server URL Prefix');
cy.get('[cy-data="server_label"]').contains('API endpoints*');

cy.get('[cy-data="server_address"]').contains('localhost');
cy.get('[cy-data="server_port"]').contains('8000');
cy.get('[cy-data="url_prefix"]').contains('api');
cy.get('[cy-data="server_address"]').contains('localhost');
cy.get('[cy-data="server_port"]').contains('8000');
cy.get('[cy-data="url_prefix"]').contains('api');

const endpoints = cy.get('[cy-data="endpoint"]');
const endpoints = cy.get('[cy-data="endpoint"]');

endpoints.should('have.length', expectedEndpoints.length);
endpoints.should('have.length', expectedEndpoints.length);

endpoints.each((endpoint) => {
expect(expectedEndpoints).to.include(endpoint.text());
});
});
endpoints.each((endpoint) => {
expect(expectedEndpoints).to.include(endpoint.text());
});
});
});
Binary file modified images/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions src/utilities/log-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const createHtml = () => {
<header>
<title>API Request Log</title>
</header>
<body style="margin: 0px; background-color: #00200B; display: flex; flex-direction: column; justify-content: center; align-items: center; min-height:100vh; font-family: sans-serif;">
<body style="margin: 0px; background: linear-gradient(120deg, #20232a 0%, #23272F 70%, #0d1117 100%); display: flex; flex-direction: column; justify-content: center; align-items: center; min-height:100vh; font-family: sans-serif;">
<h2 style="color:white" data-cy="logger-title">API Requests Made</h2>
<h3 style="color:white">File can be viewed in /src/logs folder in container or local machine</h3>
<h5 style="color:grey; margin-top:-10px;">LOG_REQUESTS env var must be set to 'ON' to log requests</h5>
<h5 style="text-align: center; color:grey; margin-top:-10px;">LOG_REQUESTS env var must be set to 'ON' to log requests <br/>AND the logger function must be implemented in the api.ts file for that endpoint</h5>
<div class="json-container" style="width: 100%; padding:20px; box-sizing: border-box;">
${prettyPrintJson.toHtml(JSON.parse(readLogs()), { indent: 4, lineNumbers: true })}
</div>
Expand Down Expand Up @@ -69,7 +69,7 @@ ol.json-lines >li::marker { font-family: system-ui, sans-serif; font-weight: nor


/* Dark Mode */
.json-container { background-color: #00200B; }
.json-container { background-color: #20232a; }
.json-key { color: indianred; }
.json-string { color: khaki}
.json-number { color: deepskyblue; }
Expand All @@ -81,8 +81,8 @@ ol.json-lines >li::marker { font-family: system-ui, sans-serif; font-weight: nor
a.json-link:hover { color: violet; }
a.json-link:active { color: slategray; }
ol.json-lines >li::marker { color: silver; }
ol.json-lines >li:nth-child(odd) { background-color: #293829; }
ol.json-lines >li:nth-child(even) { background-color: #354135; }
ol.json-lines >li:nth-child(odd) { background-color:rgb(67, 67, 67); }
ol.json-lines >li:nth-child(even) { background-color:rgb(40, 40, 40); }
ol.json-lines >li:hover { background-color: dimgray; }
</style>
</html>
Expand Down
Loading