Documents / @faasjs/server / staticHandler
Function: staticHandler()
staticHandler(
options
):Middleware
Middleware to handle static file requests.
Parameters
options
Options for the static handler.
Returns
The middleware function.
The middleware resolves the requested URL to a file path within the specified root directory. If the file exists, it reads the file content and sends it in the response. If the file does not exist, it does nothing.
Example
import { useMiddleware, staticHandler } from '@faasjs/server'
export default useMiddleware(staticHandler({ root: __dirname + '/public' }))