Skip to content

Refactor example files for reuse#6

Closed
bufferings wants to merge 13 commits intomainfrom
cursor/refactor-example-files-for-reuse-036a
Closed

Refactor example files for reuse#6
bufferings wants to merge 13 commits intomainfrom
cursor/refactor-example-files-for-reuse-036a

Conversation

@bufferings
Copy link
Copy Markdown
Owner

Refactor Kori example files to use a configure function pattern and mount them in index.ts to eliminate code duplication and improve reusability.

The original setup had individual example files that were not used by index.ts, leading to duplicated logic. This PR converts each example into a reusable configure function, which is then imported and mounted as a child application in index.ts. This also involved updating type declarations and module resolution to ensure a clean, type-safe build.

cursoragent and others added 13 commits June 30, 2025 16:12
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
Copilot AI review requested due to automatic review settings June 30, 2025 16:40
Copy link
Copy Markdown
Contributor

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 pull request refactors the Kori example files to eliminate duplicated logic by introducing a uniform configure function pattern. Key changes include updating tsconfig paths and compiler options, refactoring each example file to export a configure function, and mounting these examples in index.ts for improved reusability and type safety.

Reviewed Changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/kori-example/tsconfig.json Updated compiler options with new paths and type settings.
packages/kori-example/src/index.ts Refactored landing page and mounted examples via configure.
packages/kori-example/src/09-openapi.ts Converted to export a configure function instead of a standalone app.
packages/kori-example/src/08-error-handling.ts Refactored error handling to export a configure function.
packages/kori-example/src/07-logging.ts Updated logging endpoints with consistent type annotations.
packages/kori-example/src/06-child-instances.ts Added type support and standardized configure function export.
packages/kori-example/src/05-plugin-system.ts Refactored plugin system and integrated custom plugin demo.
packages/kori-example/src/04-lifecycle-hooks.ts Updated lifecycle hooks with explicit types and a configure export.
packages/kori-example/src/03-validation.ts Standardized validation routes with type annotations.
packages/kori-example/src/02-basic-routing.ts Refactored basic routing to export a configure function.
packages/kori-example/src/01-getting-started.ts Enhanced the getting started example with schema validation and logging.
package.json Updated dependency versions and dev dependency configuration.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment on lines +60 to +72
const requestKey = `${ctx.req.method}-${ctx.req.url.pathname}`;

for (const [key, value] of requestTimings.entries()) {
if (key.startsWith(requestKey)) {
const duration = endTime - value.startTime;
ctx.req.log.info('Request completed', {
requestNumber: value.requestNumber,
duration,
category: duration < 100 ? 'fast' : duration < 500 ? 'medium' : 'slow',
});
requestTimings.delete(key);
break;
}
Copy link

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider storing the request key (or unique request identifier) in the request context during onRequest to simplify the lookup during onResponse, instead of iterating through all map entries.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Incorrect Plugin Route Prefixing

The custom plugin route is incorrectly accessible at /custom/custom instead of /custom. This is because the createChild method sets a /custom prefix, while the route within the child is also defined at /custom. The route path within the child should be / to correctly expose the endpoint at /custom.

packages/kori-example/src/05-plugin-system.ts#L296-L306

// custom plugin demo mounted under /custom
app.createChild({
prefix: '/custom',
configure: (child) =>
child.applyPlugin(customPlugin).get('/custom', (ctx: Ctx) =>
ctx.res.json({
message: 'Custom plugin example',
customData: ctx.req.customData,
}),
),
});

Fix in Cursor


BugBot free trial expires on July 22, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

@bufferings bufferings closed this Jul 1, 2025
@bufferings bufferings deleted the cursor/refactor-example-files-for-reuse-036a branch July 1, 2025 10:31
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.

3 participants