From b61e3804cf5358124339fcd1e15002b125026396 Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Fri, 16 Jun 2023 16:14:52 +0330 Subject: [PATCH 01/12] squash and merge authentication. --- serverless/src/functions/builds/handler.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/serverless/src/functions/builds/handler.ts b/serverless/src/functions/builds/handler.ts index d2652678..d71cdbb2 100644 --- a/serverless/src/functions/builds/handler.ts +++ b/serverless/src/functions/builds/handler.ts @@ -39,7 +39,6 @@ export const submitBuildInfo = async ( }); if (buildRecord.length == 0) { - await prisma.builds.create({ data: { githubRepository: buildInfo.githubRepository, From ca02f1382ddf17bedd2b217f48ac351220c1bd65 Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Mon, 3 Jul 2023 16:56:37 +0330 Subject: [PATCH 02/12] fix: close the id generation loop in the app handler. --- serverless/src/functions/apps/handler.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/serverless/src/functions/apps/handler.ts b/serverless/src/functions/apps/handler.ts index 382a74b5..1e50110a 100644 --- a/serverless/src/functions/apps/handler.ts +++ b/serverless/src/functions/apps/handler.ts @@ -94,7 +94,7 @@ export const submitAppInfo = async ( ) { return formatJSONResponse({ status: 401, - message: 'Unauthorized', + message: 'Unauthorized.', }); } @@ -102,7 +102,7 @@ export const submitAppInfo = async ( const bunnyCdn = new BunnyCdn(process.env.BUNNY_CDN_ACCESS_KEY); const data = JSON.parse(event.body); const appInfo = { - apId: 'null', + appId: 'null', createdAt: new Date().toISOString(), sourceDomain: data.sourceDomain, hostname: data.targetDomain, @@ -116,6 +116,7 @@ export const submitAppInfo = async ( hostname?: string; }; + let errorOccurred = false; do { let id = v4(); let requestArgs: CreatePullZoneMethodArgs = { @@ -125,7 +126,7 @@ export const submitAppInfo = async ( try { pullZone = await bunnyCdn.createPullZone(requestArgs); - appInfo.apId = id; + appInfo.appId = id; } catch (error) { maxTries -= 1; if ( @@ -139,7 +140,10 @@ export const submitAppInfo = async ( throw error; } } - } while (maxTries > 0); + + errorOccurred = false; // No error occurred if this line is reached + break; // Exit the loop since catch block was not triggered + } while (maxTries > 0 && !errorOccurred); // Create custom hostname await bunnyCdn @@ -155,7 +159,7 @@ export const submitAppInfo = async ( const zoneRecord = await prisma.zones.findMany({ where: { zoneId: pullZone!.id, - name: appInfo.apId, + name: appInfo.appId, sourceDomain: appInfo.sourceDomain, }, }); @@ -164,7 +168,7 @@ export const submitAppInfo = async ( await prisma.zones.create({ data: { zoneId: pullZone!.id, - name: appInfo.apId, + name: appInfo.appId, hostname: appInfo.hostname, sourceDomain: appInfo.sourceDomain, }, From c1785d2fc3b087fee5a80f29d1acca60c57d1cc2 Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Mon, 3 Jul 2023 17:09:25 +0330 Subject: [PATCH 03/12] feat: better responses (correct status codes and articulate descriptions) --- serverless/serverless.yaml | 2 +- serverless/src/functions/apps/handler.ts | 30 ++++++++++------------ serverless/src/functions/builds/handler.ts | 10 +++----- serverless/src/functions/mints/handler.ts | 11 +++----- serverless/src/libs/api-gateway.ts | 7 +++-- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/serverless/serverless.yaml b/serverless/serverless.yaml index 3f1bba23..63b71710 100644 --- a/serverless/serverless.yaml +++ b/serverless/serverless.yaml @@ -86,7 +86,7 @@ functions: - { Ref: TopicAwsLibsLambdaLayer } - { Ref: TopicPrismaAwsPrismaClientLambdaLayer } - verifyAccessPoint: + verifyApp: handler: ./dist/src/functions/apps/handler.verifyApp events: - http: diff --git a/serverless/src/functions/apps/handler.ts b/serverless/src/functions/apps/handler.ts index 1e50110a..d1ba2ddc 100644 --- a/serverless/src/functions/apps/handler.ts +++ b/serverless/src/functions/apps/handler.ts @@ -18,9 +18,9 @@ export const verifyApp = async ( // Check the parameters and environment variables dotenv.config(); if (event.body === null || process.env.BUNNY_CDN_ACCESS_KEY === undefined) { - return formatJSONResponse({ - status: 422, - message: 'Required parameters were not passed.', + return formatJSONResponse(422, { + message: + 'Required parameters were not passed. Please check the request body and the environment variables.', }); } @@ -38,8 +38,7 @@ export const verifyApp = async ( process.env.FE_SIGNING_KEY ) ) { - return formatJSONResponse({ - status: 401, + return formatJSONResponse(401, { message: 'Unauthorized', }); } @@ -54,12 +53,11 @@ export const verifyApp = async ( await bunnyCdn.loadFreeCertificate(args); - return formatJSONResponse({ - status: true, + return formatJSONResponse(200, { + message: 'The hostname was verified successfully.', }); } catch (e) { - return formatJSONResponse({ - status: 500, + return formatJSONResponse(500, { message: e, }); } @@ -72,9 +70,9 @@ export const submitAppInfo = async ( // Check the parameters and environment variables dotenv.config(); if (event.body === null || process.env.BUNNY_CDN_ACCESS_KEY === undefined) { - return formatJSONResponse({ - status: 422, - message: 'Required parameters were not passed.', + return formatJSONResponse(422, { + message: + 'Required parameters were not passed. Please check the request body and the environment variables.', }); } @@ -92,8 +90,7 @@ export const submitAppInfo = async ( process.env.FE_SIGNING_KEY ) ) { - return formatJSONResponse({ - status: 401, + return formatJSONResponse(401, { message: 'Unauthorized.', }); } @@ -175,12 +172,11 @@ export const submitAppInfo = async ( }); } - return formatJSONResponse({ + return formatJSONResponse(200, { appInfo, }); } catch (e) { - return formatJSONResponse({ - status: 500, + return formatJSONResponse(500, { message: e, }); } diff --git a/serverless/src/functions/builds/handler.ts b/serverless/src/functions/builds/handler.ts index d71cdbb2..bab1f1ae 100644 --- a/serverless/src/functions/builds/handler.ts +++ b/serverless/src/functions/builds/handler.ts @@ -9,9 +9,8 @@ export const submitBuildInfo = async ( ): Promise => { try { if (event.body === null) { - return formatJSONResponse({ - status: 422, - message: 'Required parameters were not passed.', + return formatJSONResponse(422, { + message: 'The request body is not configured properly.', }); } @@ -82,12 +81,11 @@ export const submitBuildInfo = async ( }); } - return formatJSONResponse({ + return formatJSONResponse(200, { buildInfo, }); } catch (e) { - return formatJSONResponse({ - status: 500, + return formatJSONResponse(500, { message: e, }); } diff --git a/serverless/src/functions/mints/handler.ts b/serverless/src/functions/mints/handler.ts index 90705a75..43fbe932 100644 --- a/serverless/src/functions/mints/handler.ts +++ b/serverless/src/functions/mints/handler.ts @@ -16,8 +16,7 @@ export const submitMintInfo = async ( ): Promise => { try { if (event.body === null || event.body === undefined) { - return formatJSONResponse({ - status: 422, + return formatJSONResponse(422, { message: 'Required parameters were not passed.', }); } @@ -36,8 +35,7 @@ export const submitMintInfo = async ( process.env.ALCHEMY_SIGNING_KEY ) ) { - return formatJSONResponse({ - status: 401, + return formatJSONResponse(401, { message: 'Unauthorized', }); } @@ -216,12 +214,11 @@ export const submitMintInfo = async ( }); } - return formatJSONResponse({ + return formatJSONResponse(200, { mintInfo, }); } catch (e) { - return formatJSONResponse({ - status: 500, + return formatJSONResponse(500, { message: e, }); } diff --git a/serverless/src/libs/api-gateway.ts b/serverless/src/libs/api-gateway.ts index c1a43c54..6d7e8610 100644 --- a/serverless/src/libs/api-gateway.ts +++ b/serverless/src/libs/api-gateway.ts @@ -1,8 +1,11 @@ // QUESTION: should we add back in schema verification? -export const formatJSONResponse = (response: Record) => { +export const formatJSONResponse = ( + code: number, + response: Record +) => { return { - statusCode: 200, + statusCode: code, body: JSON.stringify(response), }; }; From 6aadb6b60639b6b5b80c631967213a349a410590 Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Mon, 3 Jul 2023 17:30:13 +0330 Subject: [PATCH 04/12] feat: add cors settings to serverless.yml --- serverless/serverless.yaml | 52 +++++++++++++++++++----------- serverless/src/libs/api-gateway.ts | 4 +++ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/serverless/serverless.yaml b/serverless/serverless.yaml index 63b71710..56240cae 100644 --- a/serverless/serverless.yaml +++ b/serverless/serverless.yaml @@ -6,18 +6,28 @@ plugins: - serverless-offline provider: - timeout: 150 - name: aws - runtime: nodejs18.x - stage: ${opt:stage, 'prd'} - region: ${opt:region, 'us-west-2'} - apiGateway: - minimumCompressionSize: 1024 - shouldStartNameWithService: true - environment: - DEBUG: '*' - AWS_STAGE: ${self:provider.stage} - AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1 + timeout: 150 + name: aws + runtime: nodejs18.x + stage: ${opt:stage, 'prd'} + region: ${opt:region, 'us-west-2'} + apiGateway: + minimumCompressionSize: 1024 + shouldStartNameWithService: true + environment: + DEBUG: '*' + AWS_STAGE: ${self:provider.stage} + AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1 + httpApi: + cors: + origin: '*' + allowedHeaders: + - lambda-signature + - x-alchemy-signature + allowedMethods: + - POST + allowCredentials: false + maxAge: 6000 # In seconds layers: TopicAwsNodeModules: @@ -27,23 +37,29 @@ layers: TopicPrismaAwsPrismaClient: path: lambda-layers-prisma-client -package: { - patterns: ["dist/**/*.prisma", "**/libquery_engine-rhel-openssl-1.0.x.so.node", "dist/serverless/.env", '!node_modules/**'], -} +package: + { + patterns: + [ + 'dist/**/*.prisma', + '**/libquery_engine-rhel-openssl-1.0.x.so.node', + 'dist/serverless/.env', + '!node_modules/**', + ], + } custom: esbuild: bundle: true minify: true sourcemap: false - exclude: + exclude: - 'aws-sdk' target: 'node18' platform: 'node' concurrency: 10 functions: - submitBuildInfo: # Deployment: handler: ./dist/src/functions/builds/handler.submitBuildInfo # TODO This will not work, need to change to nfa-serverless/dist/serverless/src/functions/builds/handler.submitBuildInfo @@ -77,7 +93,7 @@ functions: cors: true environment: # TODO They won't be loaded from the shell environment, need to find a way to pass them from the deployment script NODE_ENV: production - # DATABASE_URL: ${env:DATABASE_URL} + # DATABASE_URL: ${env:DATABASE_URL} # CONTRACT_ADDRESS: ${env:CONTRACT_ADDRESS} # PRIVATE_KEY: ${env:PRIVATE_KEY} # JSON_RPC: ${env:JSON_RPC} diff --git a/serverless/src/libs/api-gateway.ts b/serverless/src/libs/api-gateway.ts index 6d7e8610..bfc3c324 100644 --- a/serverless/src/libs/api-gateway.ts +++ b/serverless/src/libs/api-gateway.ts @@ -6,6 +6,10 @@ export const formatJSONResponse = ( ) => { return { statusCode: code, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Credentials': true, + }, body: JSON.stringify(response), }; }; From d37c9082a9a7abfbda7a1126221552f2427f5332 Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Mon, 3 Jul 2023 22:45:59 +0330 Subject: [PATCH 05/12] fix: add proper indentation to the serverless config and update app layers. --- serverless/serverless.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/serverless/serverless.yaml b/serverless/serverless.yaml index 56240cae..c19b705e 100644 --- a/serverless/serverless.yaml +++ b/serverless/serverless.yaml @@ -20,7 +20,7 @@ provider: AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1 httpApi: cors: - origin: '*' + allowedOrigins: '*' allowedHeaders: - lambda-signature - x-alchemy-signature @@ -109,6 +109,10 @@ functions: path: verifyApp method: post cors: true + layers: + - { Ref: TopicAwsNodeModulesLambdaLayer } + - { Ref: TopicAwsLibsLambdaLayer } + - { Ref: TopicPrismaAwsPrismaClientLambdaLayer } submitAppInfo: handler: ./dist/src/functions/apps/handler.submitAppInfo @@ -117,3 +121,7 @@ functions: path: app method: post cors: true + layers: + - { Ref: TopicAwsNodeModulesLambdaLayer } + - { Ref: TopicAwsLibsLambdaLayer } + - { Ref: TopicPrismaAwsPrismaClientLambdaLayer } From ea239afc729f8d59d832bdcf4960d7d7c6b3c1c0 Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Mon, 3 Jul 2023 23:15:01 +0330 Subject: [PATCH 06/12] feat: create build entity in newmints. --- subgraph/src/mint.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subgraph/src/mint.ts b/subgraph/src/mint.ts index eb1c5770..6cf5aa07 100644 --- a/subgraph/src/mint.ts +++ b/subgraph/src/mint.ts @@ -11,6 +11,7 @@ import { GitRepository, Collection, Verifier, + Build, } from '../generated/schema'; export function handleNewMint(event: NewMintEvent): void { @@ -92,6 +93,13 @@ export function handleNewMint(event: NewMintEvent): void { repository = new GitRepository(gitRepository); } + // Populate GitRepository entity + let build = new Build(Bytes.fromByteArray(Bytes.fromBigInt(tokenId))); + build.commitHash = commitHash; + build.ipfsHash = ipfsHash; + build.domain = externalURL; + build.save(); + // Increase total tokens counter const collection = Collection.load(event.address); if (collection) { From ef20b5d4b01dc26fd13e34ef4519b05f6021bbba Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Mon, 3 Jul 2023 23:16:27 +0330 Subject: [PATCH 07/12] fix: add missing gitRepository field to build entity. --- subgraph/src/mint.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/subgraph/src/mint.ts b/subgraph/src/mint.ts index 6cf5aa07..c303b2a0 100644 --- a/subgraph/src/mint.ts +++ b/subgraph/src/mint.ts @@ -98,6 +98,7 @@ export function handleNewMint(event: NewMintEvent): void { build.commitHash = commitHash; build.ipfsHash = ipfsHash; build.domain = externalURL; + build.gitRepository = gitRepository; build.save(); // Increase total tokens counter From d7bb5e6740cca88b1bc0ea4eb98edd21d4dbc65d Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Mon, 3 Jul 2023 23:35:58 +0330 Subject: [PATCH 08/12] feat: add build numbers to the entity. --- subgraph/schema.graphql | 5 +++-- subgraph/src/metadata-update.ts | 10 +++++++++- subgraph/src/mint.ts | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index ad347fe7..83408dc9 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -81,11 +81,12 @@ type Token @entity { verifier: Verifier # Address verified: Boolean! createdAt: BigInt! - builds: [Build!]! + builds: [Build!]! @derivedFrom(field: "token") } type Build @entity { - id: Bytes! # Token ID + id: Bytes! # Build number + number: Int! gitRepository: GitRepository! commitHash: String! ipfsHash: String! diff --git a/subgraph/src/metadata-update.ts b/subgraph/src/metadata-update.ts index faba2b3a..7eba4c12 100644 --- a/subgraph/src/metadata-update.ts +++ b/subgraph/src/metadata-update.ts @@ -81,9 +81,16 @@ export function handleMetadataUpdateWithMultipleStringValues( entity.save(); + // LOAD THE BUILD LIST + let token = Token.load( + Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId)) + ); + if (!token) { + return; + } // CREATE BUILD const build = new Build( - Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId)) + Bytes.fromByteArray(Bytes.fromI32(token.builds.length)) ); if (event.params.key == 'build') { let gitRepositoryEntity = GitRepositoryEntity.load(event.params.value[1]); @@ -91,6 +98,7 @@ export function handleMetadataUpdateWithMultipleStringValues( // Create a new gitRepository entity gitRepositoryEntity = new GitRepositoryEntity(event.params.value[1]); } + build.number = token.builds.length; build.commitHash = event.params.value[0]; build.gitRepository = event.params.value[1]; build.ipfsHash = event.params.value[2]; diff --git a/subgraph/src/mint.ts b/subgraph/src/mint.ts index c303b2a0..8cf26bc4 100644 --- a/subgraph/src/mint.ts +++ b/subgraph/src/mint.ts @@ -94,11 +94,13 @@ export function handleNewMint(event: NewMintEvent): void { } // Populate GitRepository entity - let build = new Build(Bytes.fromByteArray(Bytes.fromBigInt(tokenId))); + let build = new Build(Bytes.fromByteArray(Bytes.fromI32(0))); + build.number = 0; build.commitHash = commitHash; build.ipfsHash = ipfsHash; build.domain = externalURL; build.gitRepository = gitRepository; + build.token = Bytes.fromByteArray(Bytes.fromBigInt(tokenId)); build.save(); // Increase total tokens counter From 93e8e3929e4ff690c6b4882e3caa84caf9a26d96 Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Tue, 4 Jul 2023 00:46:05 +0330 Subject: [PATCH 09/12] fix: remove the derived token field. --- subgraph/schema.graphql | 2 +- subgraph/src/metadata-update.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index 83408dc9..a41d2702 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -91,7 +91,7 @@ type Build @entity { commitHash: String! ipfsHash: String! domain: String! - token: Token! @derivedFrom(field: "builds") + token: Token! } # Owner entity for collection, access points, and tokens diff --git a/subgraph/src/metadata-update.ts b/subgraph/src/metadata-update.ts index 7eba4c12..55412e23 100644 --- a/subgraph/src/metadata-update.ts +++ b/subgraph/src/metadata-update.ts @@ -103,6 +103,7 @@ export function handleMetadataUpdateWithMultipleStringValues( build.gitRepository = event.params.value[1]; build.ipfsHash = event.params.value[2]; build.domain = event.params.value[3]; + build.token = Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId)); build.save(); gitRepositoryEntity.save(); } From 83549d8af20d7096b6e0a6e99c549b3f0eb63e4f Mon Sep 17 00:00:00 2001 From: Shredder <110225819+EmperorOrokuSaki@users.noreply.github.com> Date: Fri, 7 Jul 2023 22:18:16 +0330 Subject: [PATCH 10/12] feat: allow all headers pass to functions [sls config] --- serverless/serverless.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/serverless/serverless.yaml b/serverless/serverless.yaml index c19b705e..3276fc08 100644 --- a/serverless/serverless.yaml +++ b/serverless/serverless.yaml @@ -21,9 +21,7 @@ provider: httpApi: cors: allowedOrigins: '*' - allowedHeaders: - - lambda-signature - - x-alchemy-signature + allowedHeaders: '*' allowedMethods: - POST allowCredentials: false From c75f4dcf117c0bd226519bb78c4195feeacddb8a Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Mon, 10 Jul 2023 23:41:35 +0330 Subject: [PATCH 11/12] feat: allow all headers pass to the handler function serverless.yaml config --- serverless/serverless.yaml | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/serverless/serverless.yaml b/serverless/serverless.yaml index 3276fc08..b798b2f4 100644 --- a/serverless/serverless.yaml +++ b/serverless/serverless.yaml @@ -21,7 +21,7 @@ provider: httpApi: cors: allowedOrigins: '*' - allowedHeaders: '*' + headers: '*' allowedMethods: - POST allowCredentials: false @@ -67,13 +67,12 @@ functions: - http: path: build method: post - cors: true - environment: # TODO They won't be loaded from the shell environment, need to find a way to pass them from the deployment script + cors: + origin: '*' + headers: '*' + allowCredentials: false + environment: NODE_ENV: production - # DATABASE_URL: ${env:DATABASE_URL} - # CONTRACT_ADDRESS: ${env:CONTRACT_ADDRESS} - # PRIVATE_KEY: ${env:PRIVATE_KEY} - # JSON_RPC: ${env:JSON_RPC} layers: - { Ref: TopicAwsNodeModulesLambdaLayer } - { Ref: TopicAwsLibsLambdaLayer } @@ -88,13 +87,12 @@ functions: - http: path: mint method: post - cors: true - environment: # TODO They won't be loaded from the shell environment, need to find a way to pass them from the deployment script + cors: + origin: '*' + headers: '*' + allowCredentials: false + environment: NODE_ENV: production - # DATABASE_URL: ${env:DATABASE_URL} - # CONTRACT_ADDRESS: ${env:CONTRACT_ADDRESS} - # PRIVATE_KEY: ${env:PRIVATE_KEY} - # JSON_RPC: ${env:JSON_RPC} layers: - { Ref: TopicAwsNodeModulesLambdaLayer } - { Ref: TopicAwsLibsLambdaLayer } @@ -106,7 +104,10 @@ functions: - http: path: verifyApp method: post - cors: true + cors: + origin: '*' + headers: '*' + allowCredentials: false layers: - { Ref: TopicAwsNodeModulesLambdaLayer } - { Ref: TopicAwsLibsLambdaLayer } @@ -118,7 +119,10 @@ functions: - http: path: app method: post - cors: true + cors: + origin: '*' + headers: '*' + allowCredentials: false layers: - { Ref: TopicAwsNodeModulesLambdaLayer } - { Ref: TopicAwsLibsLambdaLayer } From 58631ccbf94f9993ff1bf9a7913eecc025368d76 Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Wed, 12 Jul 2023 16:34:26 +0330 Subject: [PATCH 12/12] fix: logic of pullzone creation --- serverless/src/functions/apps/handler.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/serverless/src/functions/apps/handler.ts b/serverless/src/functions/apps/handler.ts index d1ba2ddc..f557ef7b 100644 --- a/serverless/src/functions/apps/handler.ts +++ b/serverless/src/functions/apps/handler.ts @@ -124,7 +124,9 @@ export const submitAppInfo = async ( try { pullZone = await bunnyCdn.createPullZone(requestArgs); appInfo.appId = id; + break; // Exit the loop since catch block was not triggered } catch (error) { + errorOccurred = true; maxTries -= 1; if ( error instanceof BunnyCdnError && @@ -137,10 +139,7 @@ export const submitAppInfo = async ( throw error; } } - - errorOccurred = false; // No error occurred if this line is reached - break; // Exit the loop since catch block was not triggered - } while (maxTries > 0 && !errorOccurred); + } while (maxTries > 0 && errorOccurred); // Create custom hostname await bunnyCdn