Documents / @faasjs/server / StaticHandlerOptions
Type Alias: StaticHandlerOptions
StaticHandlerOptions =
object
Properties
cache?
optional
cache:boolean
|string
Cache static files. If set to true
, the middleware will cache static files. If set to a string, the middleware will cache static files with the specified key. If set to false
, the middleware will not cache static files.
Default
true
notFound?
optional
notFound:Middleware
|boolean
|string
Not found handler.
If set to true
, the middleware will respond with a default 404 status code. If set to a string as a fallback path, the middleware will respond with the file at that path. If set to a function, the middleware will call the function with the request, response, and logger. If set to false
, the middleware will do nothing.
Default
false
root
root:
string
stripPrefix?
optional
stripPrefix:string
|RegExp
Strip prefix from the URL.
Example
import { useMiddleware, staticHandler } from '@faasjs/server'
export const func = useMiddleware(staticHandler({ root: __dirname + '/public', stripPrefix: '/public' })) // /public/index.html -> /index.html