feat: support lazily loading routes/handlers (#3131)
We can improve cold start times by only loading route modules when the particular pattern matches. This PR introduces the concept of lazy middlewares, routes and handlers to do that.
This commit is contained in:
+5
-2
@@ -103,13 +103,12 @@ export function createFakeFs(files: Record<string, unknown>): FsAdapter {
|
||||
return {
|
||||
cwd: () => ".",
|
||||
async *walk(_root) {
|
||||
// FIXME: ignore
|
||||
for (const file of Object.keys(files)) {
|
||||
const entry: WalkEntry = {
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
isSymlink: false,
|
||||
name: file, // FIXME?
|
||||
name: file,
|
||||
path: file,
|
||||
};
|
||||
yield entry;
|
||||
@@ -122,6 +121,10 @@ export function createFakeFs(files: Record<string, unknown>): FsAdapter {
|
||||
async mkdirp(_dir: string) {
|
||||
},
|
||||
readFile: Deno.readFile,
|
||||
// deno-lint-ignore require-await
|
||||
async readTextFile(path) {
|
||||
return String(files[String(path)]);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user