Skip to content

Commit b5f1c07

Browse files
committed
error handling
1 parent fcba22d commit b5f1c07

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

tooling/sparta/packages/discord/src/slashCommands/humans/verify.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export async function handleVerifyCommand(
5050
discordUserId: userId,
5151
});
5252

53+
logger.debug({ userResponse }, "User response");
54+
5355
const user = userResponse.data.user;
5456

5557
if (user) {
@@ -68,13 +70,27 @@ export async function handleVerifyCommand(
6870
);
6971

7072
logger.info(
71-
{ userId, verificationId },
73+
{ userId, verificationId, interactionToken },
7274
"Updated user verification data"
7375
);
7476
} else {
7577
// Create a new user
7678
const timestamp = Date.now();
7779

80+
logger.debug({
81+
discordUserId: userId,
82+
discordUsername,
83+
walletAddress: undefined,
84+
role: undefined,
85+
humanPassport: {
86+
status: VERIFICATION_STATUS.NOT_VERIFIED,
87+
verificationId,
88+
interactionToken,
89+
lastVerificationTime: null,
90+
score: null,
91+
},
92+
});
93+
7894
await client.createUser({
7995
discordUserId: userId,
8096
discordUsername,

tooling/sparta/packages/express/src/db/userRepository.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ interface ExtendedDynamoDB {
2828
getClient(): any;
2929
}
3030

31-
// Get the dynamoDB instance with our extended type
32-
const dynamoDB = new DynamoDBService(process.env.USERS_TABLE_NAME || "users");
31+
const USERS_TABLE_NAME = process.env.USERS_TABLE_NAME || "users";
32+
33+
// Instantiate the shared service for the users table
34+
const dynamoDB = new DynamoDBService(USERS_TABLE_NAME);
3335

3436
const extendedDynamoDB = dynamoDB as unknown as ExtendedDynamoDB;
3537

@@ -189,6 +191,8 @@ export function extendDynamoDBWithUserMethods(): void {
189191
ConditionExpression: "attribute_not_exists(discordUserId)",
190192
});
191193

194+
logger.debug({ command }, "Creating user in repository");
195+
192196
await dynamoDB.getClient().send(command);
193197
return user;
194198
} catch (error: any) {

tooling/sparta/packages/express/src/routes/users/users.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ router.post("/", async (req: Request, res: Response) => {
496496
updatedAt: timestamp,
497497
};
498498

499+
logger.debug({ newUser }, "Creating user in route");
499500
const created = await extendedDynamoDB.createUser(newUser);
500501

501502
if (!created) {

0 commit comments

Comments
 (0)