Conversation
…cation Co-authored-by: bufferings+cursor <bufferings+cursor@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Kori example files to remove duplicated route definitions by exporting configure functions from each example and mounting them in index.ts. Key changes include:
- Main
index.tsnow imports and mounts each example viacreateChild({ prefix, configure }). - Individual example files (01–09) are converted from standalone apps to
configure(app)functions. - Duplicate imports and manual route definitions are eliminated to improve maintainability.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/kori-example/src/index.ts | Mounted examples with createChild/configure. |
| packages/kori-example/src/05-plugin-system.ts | Refactored plugin example into configure functions. |
| packages/kori-example/src/06-child-instances.ts | Converted child-instances example to configure and updated type assertions. |
| packages/kori-example/src/04-lifecycle-hooks.ts | Refactored lifecycle-hooks example to configure. |
| packages/kori-example/src/01-getting-started.ts | Removed standalone app, added configure. |
Comments suppressed due to low confidence (3)
packages/kori-example/src/05-plugin-system.ts:1
- Missing imports for
timingPlugin,createCorsPlugin, andcreateRateLimitPluginwhich are applied later inconfigure. Add the appropriate import statements to avoid undefined references.
import { defineKoriPlugin, type Kori, type KoriEnvironment, type KoriRequest, type KoriResponse } from 'kori';
packages/kori-example/src/04-lifecycle-hooks.ts:1
- The
getMethodStringimport is no longer used in this file. Removing unused imports will keep the code clean.
import { getMethodString, type Kori, type KoriEnvironment, type KoriRequest, type KoriResponse } from 'kori';
packages/kori-example/src/01-getting-started.ts:8
- The
createKoriimport is no longer used after converting toconfigure. You can remove it (and any unused validator imports) to avoid dead code.
import { createKori, type Kori, type KoriEnvironment, type KoriRequest, type KoriResponse } from 'kori';
| <a href="/errors/validation">GET /errors/validation</a> | ||
| <a href="/08-error-handling/error/basic">GET /error/basic</a><br> | ||
| <a href="/08-error-handling/error/custom">GET /error/custom</a><br> | ||
| <a href="/08-error-handling/safe/divide">GET /safe/divide</a> |
There was a problem hiding this comment.
The 'safe/divide' link points to /08-error-handling, but the graceful handler is mounted under /08-graceful-errors. Update the href or the mount prefix so that the route is reachable.
| <a href="/08-error-handling/safe/divide">GET /safe/divide</a> | |
| <a href="/08-graceful-errors/safe/divide">GET /safe/divide</a> |
| .get('/users', (ctx) => | ||
| ctx.res.json({ | ||
| apiVersion: ctx.req.apiVersion, | ||
| appVersion: (ctx.req as any).appVersion, |
There was a problem hiding this comment.
[nitpick] The use of as any bypasses type safety for appVersion. Consider extending the KoriRequest type to include appVersion so you can access it without type assertions.
| appVersion: (ctx.req as any).appVersion, | |
| appVersion: ctx.req.appVersion, |
Refactor Kori example files to use
configurefunctions for reusability and eliminate code duplication inindex.ts.