@wooksjs/http-static 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,17 +1,44 @@
1
1
  import { TCacheControl } from '@wooksjs/event-http';
2
2
  import { Readable } from 'stream';
3
3
 
4
+ /** Options for configuring static file serving behavior. */
4
5
  interface TServeFileOptions {
6
+ /** Additional response headers to set. */
5
7
  headers?: Record<string, string>;
8
+ /** Cache-Control header directives. */
6
9
  cacheControl?: TCacheControl;
10
+ /** Expires header value as a Date, string, or timestamp. */
7
11
  expires?: Date | string | number;
12
+ /** When true, sets `Pragma: no-cache`. */
8
13
  pragmaNoCache?: boolean;
14
+ /** Base directory to resolve relative file paths against. */
9
15
  baseDir?: string;
16
+ /** Default file extension appended when the path has none. */
10
17
  defaultExt?: string;
18
+ /** When true, renders an HTML directory listing for directory paths. */
11
19
  listDirectory?: boolean;
20
+ /** Index filename (e.g. `'index.html'`) served when the path is a directory. */
12
21
  index?: string;
22
+ /** When true, allows `../` parent traversal in file paths. */
13
23
  allowDotDot?: boolean;
14
24
  }
25
+ /**
26
+ * Serves a static file with support for ETags, range requests, cache control, and directory listing.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * app.get('/files/*', () => {
31
+ * return serveFile('public/readme.txt', {
32
+ * baseDir: '/var/www',
33
+ * cacheControl: { maxAge: 3600 },
34
+ * })
35
+ * })
36
+ * ```
37
+ *
38
+ * @param filePath - Path to the file or directory to serve.
39
+ * @param options - Optional configuration for headers, caching, and directory behavior.
40
+ * @returns A readable stream, string body, or HTML directory listing.
41
+ */
15
42
  declare function serveFile(filePath: string, options?: TServeFileOptions): Promise<Readable | string | string[] | unknown>;
16
43
 
17
44
  export { serveFile };