Skip to content

Commit 23734a0

Browse files
authored
docs(core): improve CORS example documentation on JSR (freshframework#3602)
Improves clarity of CORS JSDoc example for JSR: <img width="1088" height="706" alt="image" src="https://github.com/user-attachments/assets/8ea3b6f9-a5ee-41cc-9512-a3a0fb87a4c0" /> ## Changes - Split the example into two: Basic & Advances - Uncomment "Advanced" example
1 parent 6a1ce91 commit 23734a0

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

packages/fresh/src/dev/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class Builder<State = any> {
213213
* This can also be used for testing to apply a snapshot to a particular
214214
* {@linkcode App} instance.
215215
*
216-
* @example
216+
* @example Testing
217217
* ```ts
218218
* const builder = new Builder();
219219
* const applySnapshot = await builder.build({ snapshot: "memory" });

packages/fresh/src/middlewares/cors.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type CORSOptions<State> = {
3737
* @param [options] - The options for the CORS middleware.
3838
* @returns The Fresh middleware handler function.
3939
*
40-
* @example
40+
* @example Basic usage
4141
* ```ts
4242
* // main.ts or routes/_middleware.ts
4343
* import { cors } from 'fresh';
@@ -46,19 +46,21 @@ export type CORSOptions<State> = {
4646
* cors({ origin: '*' }), // Allow all origins
4747
* // other middlewares or main route handler
4848
* ];
49+
* ```
4950
*
50-
* // Example with options:
51-
* // export const handler = [
52-
* // cors({
53-
* // origin: 'http://example.com',
54-
* // allowHeaders: ['X-Custom-Header', 'Upgrade-Insecure-Requests'],
55-
* // allowMethods: ['POST', 'GET', 'OPTIONS'],
56-
* // exposeHeaders: ['Content-Length', 'X-Kuma-Revision'],
57-
* // maxAge: 600,
58-
* // credentials: true,
59-
* // }),
60-
* // // ...
61-
* // ];
51+
* @example Advanced usage
52+
* ```ts
53+
* export const handler = [
54+
* cors({
55+
* origin: 'http://example.com',
56+
* allowHeaders: ['X-Custom-Header', 'Upgrade-Insecure-Requests'],
57+
* allowMethods: ['POST', 'GET', 'OPTIONS'],
58+
* exposeHeaders: ['Content-Length', 'X-Kuma-Revision'],
59+
* maxAge: 600,
60+
* credentials: true,
61+
* }),
62+
* // ...
63+
* ];
6264
* ```
6365
*/
6466
export function cors<State>(options?: CORSOptions<State>): Middleware<State> {

0 commit comments

Comments
 (0)