Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!isFile)
throw new HttpStatusError(HttpStatus.NotFound)
ctx.type = extname(this.body)
const sendFile = ctx.config.sendFile || ((path: string, opt?: ServeStaticOptions) => send(ctx, path, opt))
await sendFile(this.body, this.opt)
}
}
// --------------------------------------------------------------------- //
// ----------------------------- DECORATORS ---------------------------- //
// --------------------------------------------------------------------- //
response.file = (path: string, opt?: ServeStaticOptions) => new FileActionResult(path, opt)
route.historyApiFallback = () => {
return decorateMethod({ type: "HistoryApiFallback" })
}
// --------------------------------------------------------------------- //
// ---------------------------- MIDDLEWARES ---------------------------- //
// --------------------------------------------------------------------- //
export class ServeStaticMiddleware implements Middleware {
constructor(public option: ServeStaticOptions) { }
async execute(invocation: Readonly): Promise {
if(this.option.rootPath && !this.option.rootPath.startsWith("/"))
this.option.rootPath = "/" + this.option.rootPath
const rootPath = this.option.rootPath || ""
//no route = no controller = possibly static file request