How to use the @plumier/core.route.historyApiFallback function in @plumier/core

To help you get started, we’ve selected a few @plumier/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plumier / plumier / packages / serve-static / src / index.ts View on Github external
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