feat: a new "island" based architechture (#97)
This commit is contained in:
+14
-5
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user