MCPcopy Index your code
hub / github.com/CapSoftware/Cap / register

Function register

apps/web/instrumentation.node.ts:14–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12import { buildEnv, serverEnv } from "@cap/env";
13
14export async function register() {
15 if (process.env.NEXT_PUBLIC_IS_CAP) return;
16
17 console.log("Waiting 5 seconds to run migrations");
18 // Function to trigger migrations with retry logic
19 const triggerMigrations = async (retryCount = 0, maxRetries = 3) => {
20 try {
21 await runMigrations();
22 } catch (error) {
23 console.error(
24 `🚨 Error triggering migrations (attempt ${retryCount + 1}):`,
25 error,
26 );
27 if (retryCount < maxRetries - 1) {
28 console.log(
29 `🔄 Retrying in 5 seconds... (${retryCount + 1}/${maxRetries})`,
30 );
31 setTimeout(() => triggerMigrations(retryCount + 1, maxRetries), 5000);
32 } else {
33 console.error(`🚨 All ${maxRetries} migration attempts failed.`);
34 process.exit(1); // Exit with error code if all attempts fail
35 }
36 }
37 };
38 // Add a timeout to trigger migrations after 5 seconds on server start
39 setTimeout(() => triggerMigrations(), 5000);
40 setTimeout(() => createS3Bucket(), 5000);
41}
42
43async function createS3Bucket() {
44 const s3Client = new S3Client({

Callers

nothing calls this directly

Calls 2

triggerMigrationsFunction · 0.85
createS3BucketFunction · 0.85

Tested by

no test coverage detected