Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPrimata committed Oct 10, 2024
1 parent 541ed46 commit d445483
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/rate-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export default async function handler(request: any, response: any) {
const verificationUrl = `https://www.google.com/recaptcha/api/siteverify?secret=${secretKey}&response=${token}`;

if (!secretKey || !process.env.FAUCET_AUTH_TOKEN) {
console.log(`secret key not set`);
return request.status(500).json({error: "reCAPTCHA secret key not set"});
}
console.log(`keys exist`);
const ip = ips(request) ?? "127.0.0.1";

// const score = await createAssessment("movement-faucet-1722352143785", "6LdVjR0qAAAAAFSjzYqyRFsnUDn-iRrzQmv0nnp3", "", token);
Expand All @@ -111,14 +111,15 @@ export default async function handler(request: any, response: any) {
);

if (!success) {
console.log(`ip rate limit`);
return response.status(429).json({success: false, error: "IP rate limited"});
}

if (!addressSuccess) {
console.log(`address rate limit`);
return response.status(429).json({success: false, error: "Address rate limited"});
}

console.log(`successful rate limit`);
const verification = await fetch(verificationUrl, {method: "POST"});
try {
const data = await verification.json();
Expand All @@ -127,7 +128,6 @@ export default async function handler(request: any, response: any) {
.status(400)
.json({success: false, error: "Invalid reCAPTCHA token"});
}
console.log(`successful recaptcha`);
const HEADERS = {
authorization: `Bearer ${process.env.FAUCET_AUTH_TOKEN}`,
};
Expand All @@ -145,11 +145,11 @@ export default async function handler(request: any, response: any) {
amount: 1000000000,
});
if (!fund.success) {
console.log(`failed to fund account`);
return response
.status(400)
.json({success: false, error: "Failed to fund account"});
}
console.log(`successful funding`);

return response
.status(200)
Expand Down

0 comments on commit d445483

Please sign in to comment.