optimized local api instantiation to prepare for nextjs app router

This commit is contained in:
dswbx
2025-02-20 10:02:44 +01:00
parent eaa7276173
commit 6f776aeff7
9 changed files with 123 additions and 122 deletions

View File

@@ -10,7 +10,10 @@ type RemixContext = {
let app: App;
let building: boolean = false;
export async function getApp(config: RemixBkndConfig, args?: RemixContext) {
export async function getApp<Args extends RemixContext = RemixContext>(
config: RemixBkndConfig<Args>,
args?: Args
) {
if (building) {
while (building) {
await new Promise((resolve) => setTimeout(resolve, 5));
@@ -31,7 +34,7 @@ export function serve<Args extends RemixContext = RemixContext>(
config: RemixBkndConfig<Args> = {}
) {
return async (args: Args) => {
app = await createFrameworkApp(config, args);
app = await getApp(config, args);
return app.fetch(args.request);
};
}