Add support for registering vendor asset routes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-07-07 22:50:48 -05:00
parent 39d97d6e14
commit e33d8dee8f
10 changed files with 142 additions and 14 deletions

View File

@@ -156,6 +156,15 @@ export function staticServer(options: StaticServerOptions = {}): RouteHandler {
// If the resolved path is a directory, send the directory listing response
if ( await filePath.isDirectory() ) {
if ( !options.directoryListing ) {
throw new StaticServerHTTPError(HTTPStatus.NOT_FOUND, 'File not found', {
basePath: basePath.toString(),
filePath: filePath.toString(),
route: route.path,
reason: 'Path is a directory, and directory listing is disabled',
})
}
if ( !route.path.endsWith('/') ) {
return redirect(`${route.path}/`)
}