Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(jsdoc): Compress Middleware #2697

Merged
merged 1 commit into from
May 18, 2024
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
16 changes: 16 additions & 0 deletions deno_dist/middleware/compress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ interface CompressionOptions {
encoding?: (typeof ENCODING_TYPES)[number]
}

/**
* Compress middleware for Hono.
*
* @see {@link https://hono.dev/middleware/builtin/compress}
*
* @param {CompressionOptions} [options] - The options for the compress middleware.
* @param {'gzip' | 'deflate'} [options.encoding] - The compression scheme to allow for response compression. Either 'gzip' or 'deflate'. If not defined, both are allowed and will be used based on the Accept-Encoding header. 'gzip' is prioritized if this option is not provided and the client provides both in the Accept-Encoding header.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(compress())
* ```
*/
export const compress = (options?: CompressionOptions): MiddlewareHandler => {
return async function compress(ctx, next) {
await next()
Expand Down
16 changes: 16 additions & 0 deletions src/middleware/compress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ interface CompressionOptions {
encoding?: (typeof ENCODING_TYPES)[number]
}

/**
* Compress middleware for Hono.
*
* @see {@link https://hono.dev/middleware/builtin/compress}
*
* @param {CompressionOptions} [options] - The options for the compress middleware.
* @param {'gzip' | 'deflate'} [options.encoding] - The compression scheme to allow for response compression. Either 'gzip' or 'deflate'. If not defined, both are allowed and will be used based on the Accept-Encoding header. 'gzip' is prioritized if this option is not provided and the client provides both in the Accept-Encoding header.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(compress())
* ```
*/
export const compress = (options?: CompressionOptions): MiddlewareHandler => {
return async function compress(ctx, next) {
await next()
Expand Down