feat(server): plugins can add middlewares and routes (#1455)

Co-authored-by: RoeHH <git@roeh.ch>
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
Reed von Redwitz
2023-07-13 11:26:07 +02:00
committed by GitHub
co-authored by RoeHH Marvin Hagemeister
parent 7dee138bee
commit 50db296fb7
10 changed files with 171 additions and 4 deletions
+21
View File
@@ -337,6 +337,10 @@ export interface Plugin {
* propagate state between the render hook and the renderer.
*/
renderAsync?(ctx: PluginAsyncRenderContext): Promise<PluginRenderResult>;
routes?: PluginRoute[];
middlewares?: PluginMiddleware[];
}
export interface PluginRenderContext {
@@ -387,3 +391,20 @@ export interface PluginRenderFunctionResult {
* client. */
requiresHydration: boolean;
}
export interface PluginMiddleware {
/** A path in the format of a filename path without filetype */
path: string;
middleware: Middleware;
}
export interface PluginRoute {
/** A path in the format of a filename path without filetype */
path: string;
component?: ComponentType<PageProps> | ComponentType<AppProps>;
// deno-lint-ignore no-explicit-any
handler?: Handler<any, any> | Handlers<any, any>;
}