blog infra

This commit is contained in:
Emergent Reasons
2025-10-16 06:23:59 +00:00
parent 4740d39105
commit 0841917e09
16 changed files with 2703 additions and 190 deletions
+5 -3
View File
@@ -110,12 +110,14 @@ export class BCMRHttp extends BaseBCMR {
);
// Validate the payload body.
try{
try {
const metadata = MetadataRegistrySchema.parse(await response.json());
return metadata;
} catch(error: unknown) {
throw new Error(`Unable to parse the metadata registry format. Detailed error: ${error}`);
} catch (error: unknown) {
throw new Error(
`Unable to parse the metadata registry format. Detailed error: ${error}`,
);
}
}
+7 -2
View File
@@ -83,10 +83,15 @@ export function findAllKeyOcurrences(
const keyValues: Array<unknown> = [];
function traverse(currentObj: Record<string | number | symbol, unknown>, depth: number = 0) {
function traverse(
currentObj: Record<string | number | symbol, unknown>,
depth: number = 0,
) {
// Stop if depth exceeds the amount of 'allowedNestedLevels'.
if (depth > allowedNestedLevels)
throw new Error(`Maximum nesting level of ${allowedNestedLevels} reached.`);
throw new Error(
`Maximum nesting level of ${allowedNestedLevels} reached.`,
);
// Stop when find a non object value.
if (typeof currentObj !== 'object' || currentObj === null) return;
@@ -41,6 +41,8 @@ describe('BCMRComposite', () => {
test('should fail if cantegoryId is not a registered entry', async () => {
const invalidCategoryId = 'asd123';
await expect(bcmrComposite.getTokenData(invalidCategoryId)).rejects.toThrow();
await expect(
bcmrComposite.getTokenData(invalidCategoryId),
).rejects.toThrow();
});
});