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:
co-authored by
RoeHH
Marvin Hagemeister
parent
7dee138bee
commit
50db296fb7
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user