Options for serving static files from a directory

Hierarchy

  • DirOptions

Properties

glob?: string

Limits the files served to only those matching the specified glob pattern. See https://github.com/isaacs/node-glob#glob-primer for the syntax supported.

ignore?: string | string[]

Glob pattern of files to exclude

paths?: ((file: string) => string[])

Type declaration

    • (file: string): string[]
    • By default the path on which files are served corresponds to the path within the directory, so for example, public/css/main.css would be served at '/css/main.css', you can override this using the paths option. For each file, the function is passed the path to the file within the directory. The function should return the URL paths on which the file should be served.

      Parameters

      • file: string

      Returns string[]

rewritePathSource?: string

Defines the rewrite source in serveStatic as this cannot be inferred from the criteria as in case when path criteria is string array (InOperatorValues), we need to decide which source to use for multiple paths.

Default

'/:path*'

sort?: ((files: string[]) => string[])

Type declaration

    • (files: string[]): string[]
    • An optional function to sort the files before mapping them to routes

      Parameters

      • files: string[]

      Returns string[]

Generated using TypeDoc