|
1 | | -import type { H3Event } from 'h3' |
2 | | -import type { RenderResponse } from './helper' |
3 | | -import { compress, getAnyCompression } from './helper' |
4 | | - |
5 | | -export async function useGZipCompression( |
6 | | - event: H3Event, |
7 | | - response: Partial<RenderResponse>, |
8 | | -) { |
9 | | - await compress(event, response, 'deflate') |
10 | | -} |
11 | | - |
12 | | -export async function useDeflateCompression( |
13 | | - event: H3Event, |
14 | | - response: Partial<RenderResponse>, |
15 | | -) { |
16 | | - await compress(event, response, 'deflate') |
17 | | -} |
18 | | - |
19 | | -export async function useBrotliCompression( |
20 | | - event: H3Event, |
21 | | - response: Partial<RenderResponse>, |
22 | | -) { |
23 | | - await compress(event, response, 'br') |
24 | | -} |
25 | | - |
26 | | -export async function useCompression( |
27 | | - event: H3Event, |
28 | | - response: Partial<RenderResponse>, |
29 | | -) { |
30 | | - const compression = getAnyCompression(event) |
31 | | - if (compression) |
32 | | - await compress(event, response, compression) |
33 | | -} |
| 1 | +import type { H3Event } from 'h3' |
| 2 | +import type { RenderResponse } from './helper' |
| 3 | +import { compress, getAnyCompression } from './helper' |
| 4 | + |
| 5 | +export async function useGZipCompression( |
| 6 | + event: H3Event, |
| 7 | + response: Partial<RenderResponse>, |
| 8 | +) { |
| 9 | + await compress(event, response, 'gzip') |
| 10 | +} |
| 11 | + |
| 12 | +export async function useDeflateCompression( |
| 13 | + event: H3Event, |
| 14 | + response: Partial<RenderResponse>, |
| 15 | +) { |
| 16 | + await compress(event, response, 'deflate') |
| 17 | +} |
| 18 | + |
| 19 | +export async function useBrotliCompression( |
| 20 | + event: H3Event, |
| 21 | + response: Partial<RenderResponse>, |
| 22 | +) { |
| 23 | + await compress(event, response, 'br') |
| 24 | +} |
| 25 | + |
| 26 | +export async function useCompression( |
| 27 | + event: H3Event, |
| 28 | + response: Partial<RenderResponse>, |
| 29 | +) { |
| 30 | + const compression = getAnyCompression(event) |
| 31 | + if (compression) |
| 32 | + await compress(event, response, compression) |
| 33 | +} |
0 commit comments