chore: remove extra code & logging & error messages, fix quick-start documentation

This commit is contained in:
2025-09-14 17:25:11 -06:00
parent 69e29ecf85
commit f371ce88a0
4 changed files with 29 additions and 58 deletions

View File

@@ -16,7 +16,7 @@
* @module endorserServer
*/
import { Axios, AxiosRequestConfig } from "axios";
import { Axios, AxiosRequestConfig, AxiosResponse } from "axios";
import { Buffer } from "buffer";
import { sha256 } from "ethereum-cryptography/sha256";
import { LRUCache } from "lru-cache";
@@ -1131,7 +1131,7 @@ export async function createAndSubmitClaim(
// Enhanced diagnostic logging for claim submission
const requestId = `claim_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
logger.info("[Claim Submission] 🚀 Starting claim submission:", {
logger.debug("[Claim Submission] 🚀 Starting claim submission:", {
requestId,
apiServer,
requesterDid: issuerDid,
@@ -1157,7 +1157,7 @@ export async function createAndSubmitClaim(
},
});
logger.info("[Claim Submission] ✅ Claim submitted successfully:", {
logger.debug("[Claim Submission] ✅ Claim submitted successfully:", {
requestId,
status: response.status,
handleId: response.data?.handleId,
@@ -1754,7 +1754,7 @@ export async function fetchImageRateLimits(
axios: Axios,
issuerDid: string,
imageServer?: string,
) {
): Promise<AxiosResponse | null> {
const server = imageServer || DEFAULT_IMAGE_API_SERVER;
const url = server + "/image-limits";
const headers = await getHeaders(issuerDid);
@@ -1788,7 +1788,7 @@ export async function fetchImageRateLimits(
};
};
logger.warn("[Image Server] Image rate limits check failed:", {
logger.error("[Image Server] Image rate limits check failed:", {
did: issuerDid,
server: server,
errorCode: axiosError.response?.data?.error?.code,
@@ -1796,7 +1796,6 @@ export async function fetchImageRateLimits(
httpStatus: axiosError.response?.status,
timestamp: new Date().toISOString(),
});
throw error;
return null;
}
}

View File

@@ -511,7 +511,7 @@ export async function runMigrations<T>(
try {
migrationLog("📋 [Migration] Starting migration process...");
// Step 1: Create migrations table if it doesn't exist
// Create migrations table if it doesn't exist
// Note: We use IF NOT EXISTS here because this is infrastructure, not a business migration
await sqlExec(`
CREATE TABLE IF NOT EXISTS migrations (
@@ -520,41 +520,14 @@ export async function runMigrations<T>(
);
`);
// Step 2: Handle migration name changes (master branch compatibility)
// Map old migration names to new ones
const migrationNameMap = new Map([
// No longer needed - migrations consolidated into single 003
]);
// Update any old migration names to new ones
for (const [oldName, newName] of migrationNameMap) {
try {
await sqlExec("UPDATE migrations SET name = ? WHERE name = ?", [
newName,
oldName,
]);
if (
await sqlQuery("SELECT 1 FROM migrations WHERE name = ? LIMIT 1", [
newName,
])
) {
migrationLog(
`🔄 [Migration] Renamed migration: ${oldName}${newName}`,
);
}
} catch (error) {
// Ignore errors - migration might not exist
}
}
// Step 3: Get list of already applied migrations
// Step 2: Get list of already applied migrations
const appliedMigrationsResult = await sqlQuery(
"SELECT name FROM migrations",
);
const appliedMigrations = extractMigrationNames(appliedMigrationsResult);
// Step 4: Get all registered migrations
// Step 3: Get all registered migrations
const migrations = migrationRegistry.getMigrations();
if (migrations.length === 0) {
@@ -569,7 +542,7 @@ export async function runMigrations<T>(
let appliedCount = 0;
let skippedCount = 0;
// Step 5: Process each migration
// Step 4: Process each migration
for (const migration of migrations) {
// Check 1: Is it recorded as applied in migrations table?
const isRecordedAsApplied = appliedMigrations.has(migration.name);
@@ -719,7 +692,7 @@ export async function runMigrations<T>(
}
}
// Step 5: Final validation - verify all migrations are properly recorded
// Step 6: Final validation - verify all migrations are properly recorded
const finalMigrationsResult = await sqlQuery("SELECT name FROM migrations");
const finalAppliedMigrations = extractMigrationNames(finalMigrationsResult);

View File

@@ -1446,12 +1446,11 @@ export default class AccountViewView extends Vue {
this.DEFAULT_IMAGE_API_SERVER,
);
if (imageResp.status === 200) {
if (imageResp && imageResp.status === 200) {
this.imageLimits = imageResp.data;
} else {
this.limitsMessage = ACCOUNT_VIEW_CONSTANTS.LIMITS.NO_IMAGE_ACCESS;
this.notify.warning(ACCOUNT_VIEW_CONSTANTS.LIMITS.CANNOT_UPLOAD_IMAGES);
return;
}
const endorserResp = await fetchEndorserRateLimits(
@@ -1465,7 +1464,6 @@ export default class AccountViewView extends Vue {
} else {
this.limitsMessage = ACCOUNT_VIEW_CONSTANTS.LIMITS.NO_LIMITS_FOUND;
this.notify.warning(ACCOUNT_VIEW_CONSTANTS.LIMITS.BAD_SERVER_RESPONSE);
return;
}
} catch (error) {
this.limitsMessage =
@@ -1482,6 +1480,7 @@ export default class AccountViewView extends Vue {
error: error instanceof Error ? error.message : String(error),
did: did,
apiServer: this.apiServer,
imageServer: this.DEFAULT_IMAGE_API_SERVER,
partnerApiServer: this.partnerApiServer,
errorCode: axiosError?.response?.data?.error?.code,
errorMessage: axiosError?.response?.data?.error?.message,
@@ -1996,7 +1995,7 @@ export default class AccountViewView extends Vue {
error: error instanceof Error ? error.message : String(error),
timestamp: new Date().toISOString(),
});
throw new Error("Failed to load profile");
return null;
}
}