Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

w3nl
Copy link
Contributor

@w3nl w3nl commented Jul 31, 2025

No description provided.

@w3nl w3nl requested a review from Copilot July 31, 2025 13:38
@w3nl w3nl changed the base branch from main to v1.x July 31, 2025 13:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive cache control for API documentation endpoints by adding ETag and Cache-Control headers, supporting HTTP 304 responses, and includes a major code style refactoring from semicolons to semicolon-free JavaScript style.

  • Adds ETag-based caching for /api-docs endpoints with Cache-Control headers
  • Refactors entire codebase from semicolon style to semicolon-free style
  • Updates build configuration and dependencies to modern versions

Reviewed Changes

Copilot reviewed 27 out of 33 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/api.js Implements ETag generation and conditional request handling for api-docs endpoint
src/server.test.js Updates tests to verify cache headers and 304 response behavior
src/server.js Adds maximumBodySize parameter and removes semicolons
src/types.js Code style change removing trailing comma and semicolons
package.json Major version bump and dependency updates
eslint.config.js New ESLint configuration file replacing .eslintrc

if (this.apiDocs) {
// Generate an ETag for the specification (simple hash or JSON string)
const apiDocsString = JSON.stringify(this.specification)
const etag = `"${crypto.createHash('sha256').update(apiDocsString).digest('base64')}"`
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The ETag generation uses SHA-256 hash which may be overkill for this use case. Consider using a simpler hash algorithm like MD5 or a content-based hash for better performance, as ETags don't require cryptographic security.

Suggested change
const etag = `"${crypto.createHash('sha256').update(apiDocsString).digest('base64')}"`
const etag = `"${crypto.createHash('md5').update(apiDocsString).digest('base64')}"`

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
Comment on lines 107 to 108
const etags = ifNoneMatchHeader.split(',').map((tag) => tag.trim())
if (etags.includes('*') || etags.includes(etag)) {
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ETag parsing logic doesn't handle quoted ETags correctly. ETags can be quoted ("etag") or unquoted, and the current implementation may not match properly. Consider using a more robust ETag comparison that handles both formats.

Suggested change
const etags = ifNoneMatchHeader.split(',').map((tag) => tag.trim())
if (etags.includes('*') || etags.includes(etag)) {
const etags = ifNoneMatchHeader.split(',').map((tag) => tag.trim().replace(/^"(.*)"$/, '$1'))
if (etags.includes('*') || etags.includes(etag.replace(/^"(.*)"$/, '$1'))) {

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
},
];
{
name: 'apiKey',
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The security handler name changed from 'customSecurityHandler' to 'apiKey' but this appears to be inconsistent with the second handler that still uses 'customSecurityHandler'. This could cause authentication issues if the API expects consistent handler names.

Suggested change
name: 'apiKey',
name: 'customSecurityHandler',

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
)

await t.test(
'It should response with a 403 message if you forgot the secret in the header',
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: 'response' should be 'respond' - the correct phrase is 'It should respond with a 403 message'.

Suggested change
'It should response with a 403 message if you forgot the secret in the header',
'It should respond with a 403 message if you forgot the secret in the header',

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
async () => {
const response = await request.get('/v1/user');
await t.test(
'It should return the mocked user, because we don\'t have a controller yet',
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Grammar error: 'return' should be 'response with' or the sentence should be restructured - consider 'It should return the mocked user because we don't have a controller yet' or 'It should respond with the mocked user...'.

Suggested change
'It should return the mocked user, because we don\'t have a controller yet',
'It should respond with the mocked user, because we don\'t have a controller yet',

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
"name": "@trojs/openapi-server",
"description": "OpenAPI Server",
"version": "1.2.5",
"version": "1.13.0",
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The version jump from 1.2.5 to 1.13.0 is unusually large for what appears to be primarily a caching feature addition and code style changes. Consider if this should be a minor version bump instead (1.3.0) unless there are breaking changes not visible in the diff.

Suggested change
"version": "1.13.0",
"version": "1.3.0",

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
@w3nl w3nl merged commit 9174bd6 into v1.x Jul 31, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.