feat: a new "island" based architechture (#97)

This commit is contained in:
Luca Casonato
2022-03-04 19:49:27 +01:00
committed by GitHub
parent d441bf2489
commit 8daa280862
70 changed files with 820 additions and 972 deletions
+14 -5
View File
@@ -2,26 +2,35 @@ import { ServerContext } from "./context.ts";
import { listenAndServe } from "./deps.ts";
import {
AppModule,
ErrorPageModule,
IslandModule,
MiddlewareModule,
PageModule,
RendererModule,
UnknownPageModule,
} from "./types.ts";
export type { Handler, HandlerContext, Handlers } from "./types.ts";
export { RenderContext } from "./render.tsx";
export type { RenderFn } from "./render.tsx";
export interface Routes {
pages: Record<
export interface Manifest {
routes: Record<
string,
PageModule | RendererModule | MiddlewareModule | AppModule
| PageModule
| RendererModule
| MiddlewareModule
| AppModule
| ErrorPageModule
| UnknownPageModule
>;
islands: Record<string, IslandModule>;
baseUrl: string;
}
export { ServerContext };
export async function start(routes: Routes) {
const ctx = await ServerContext.fromRoutes(routes);
export async function start(routes: Manifest) {
const ctx = await ServerContext.fromManifest(routes);
console.log("Server listening on http://localhost:8000");
await listenAndServe(":8000", ctx.handler());
}