Skip to content

🎥 Make videos programmatically with React

Update route.ts

Jonny Burger59ba3e07c2ad
diff --git a/packages/template-vercel/src/app/api/render/route.ts b/packages/template-vercel/src/app/api/render/route.ts
index 89b27f6fd7..dd2b4de0a9 100644
--- a/packages/template-vercel/src/app/api/render/route.ts
+++ b/packages/template-vercel/src/app/api/render/route.ts
@@ -90,12 +90,18 @@ export async function POST(req: Request) {
detached: true,
});
+ // We empirically tested how many lines are printed to stdout when installing the system dependencies:
+ const EXPECTED_SYS_INSTALL_LINES = 272;
let sysInstallLineCount = 0;
- for await (const log of sysInstallCmd.logs()) {
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ for await (const _log of sysInstallCmd.logs()) {
sysInstallLineCount++;
- await send({ type: "log", stream: log.stream, data: log.data });
+ const progress = Math.min(
+ sysInstallLineCount / EXPECTED_SYS_INSTALL_LINES,
+ 1,
+ );
+ await send({ type: "progress", progress });
}
- console.log("sysInstallLineCount:", sysInstallLineCount);
const sysInstallResult = await sysInstallCmd.wait();
if (sysInstallResult.exitCode !== 0) {