Skip to content

Commit f2f4716

Browse files
committed
lint
1 parent e6c4082 commit f2f4716

File tree

1 file changed

+55
-55
lines changed

1 file changed

+55
-55
lines changed

src/server/middleware/adminRoutes.ts

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -22,71 +22,71 @@ const ADMIN_ROUTES_PASSWORD = env.THIRDWEB_API_SECRET_KEY;
2222

2323
// Add queues to monitor here.
2424
const QUEUES: Queue[] = [
25-
SendWebhookQueue.q,
26-
ProcessEventsLogQueue.q,
27-
ProcessTransactionReceiptsQueue.q,
28-
SendTransactionQueue.q,
29-
MineTransactionQueue.q,
30-
CancelRecycledNoncesQueue.q,
31-
PruneTransactionsQueue.q,
32-
NonceResyncQueue.q,
33-
NonceHealthCheckQueue.q,
25+
SendWebhookQueue.q,
26+
ProcessEventsLogQueue.q,
27+
ProcessTransactionReceiptsQueue.q,
28+
SendTransactionQueue.q,
29+
MineTransactionQueue.q,
30+
CancelRecycledNoncesQueue.q,
31+
PruneTransactionsQueue.q,
32+
NonceResyncQueue.q,
33+
NonceHealthCheckQueue.q,
3434
];
3535

3636
export const withAdminRoutes = async (fastify: FastifyInstance) => {
37-
fastify.after(async () => {
38-
// Create a new route for Bullboard routes.
39-
const serverAdapter = new FastifyAdapter();
40-
serverAdapter.setBasePath(ADMIN_QUEUES_BASEPATH);
37+
fastify.after(async () => {
38+
// Create a new route for Bullboard routes.
39+
const serverAdapter = new FastifyAdapter();
40+
serverAdapter.setBasePath(ADMIN_QUEUES_BASEPATH);
4141

42-
createBullBoard({
43-
queues: QUEUES.map((q) => new BullMQAdapter(q)),
44-
serverAdapter,
45-
});
42+
createBullBoard({
43+
queues: QUEUES.map((q) => new BullMQAdapter(q)),
44+
serverAdapter,
45+
});
4646

47-
await fastify.register(serverAdapter.registerPlugin(), {
48-
basePath: ADMIN_QUEUES_BASEPATH,
49-
prefix: ADMIN_QUEUES_BASEPATH,
50-
});
47+
await fastify.register(serverAdapter.registerPlugin(), {
48+
basePath: ADMIN_QUEUES_BASEPATH,
49+
prefix: ADMIN_QUEUES_BASEPATH,
50+
});
5151

52-
fastify.addHook("onRequest", async (req, reply) => {
53-
if (req.url.startsWith(ADMIN_QUEUES_BASEPATH)) {
54-
const authHeader = req.headers.authorization;
52+
fastify.addHook("onRequest", async (req, reply) => {
53+
if (req.url.startsWith(ADMIN_QUEUES_BASEPATH)) {
54+
const authHeader = req.headers.authorization;
5555

56-
if (!authHeader || !authHeader.startsWith("Basic ")) {
57-
reply
58-
.status(StatusCodes.UNAUTHORIZED)
59-
.header("WWW-Authenticate", 'Basic realm="Admin Routes"')
60-
.send({ error: "Unauthorized" });
61-
return;
62-
}
56+
if (!authHeader || !authHeader.startsWith("Basic ")) {
57+
reply
58+
.status(StatusCodes.UNAUTHORIZED)
59+
.header("WWW-Authenticate", 'Basic realm="Admin Routes"')
60+
.send({ error: "Unauthorized" });
61+
return;
62+
}
6363

64-
// Parse the basic auth credentials (`Basic <base64 of username:password>`).
65-
const base64Credentials = authHeader.split(" ")[1];
66-
const credentials = Buffer.from(base64Credentials, "base64").toString(
67-
"utf8",
68-
);
69-
const [username, password] = credentials.split(":");
64+
// Parse the basic auth credentials (`Basic <base64 of username:password>`).
65+
const base64Credentials = authHeader.split(" ")[1];
66+
const credentials = Buffer.from(base64Credentials, "base64").toString(
67+
"utf8",
68+
);
69+
const [username, password] = credentials.split(":");
7070

71-
if (!assertAdminBasicAuth(username, password)) {
72-
reply
73-
.status(StatusCodes.UNAUTHORIZED)
74-
.header("WWW-Authenticate", 'Basic realm="Admin Routes"')
75-
.send({ error: "Unauthorized" });
76-
return;
77-
}
78-
}
79-
});
80-
});
71+
if (!assertAdminBasicAuth(username, password)) {
72+
reply
73+
.status(StatusCodes.UNAUTHORIZED)
74+
.header("WWW-Authenticate", 'Basic realm="Admin Routes"')
75+
.send({ error: "Unauthorized" });
76+
return;
77+
}
78+
}
79+
});
80+
});
8181
};
8282

8383
const assertAdminBasicAuth = (username: string, password: string) => {
84-
if (username === ADMIN_ROUTES_USERNAME) {
85-
try {
86-
const buf1 = Buffer.from(password.padEnd(100));
87-
const buf2 = Buffer.from(ADMIN_ROUTES_PASSWORD.padEnd(100));
88-
return timingSafeEqual(buf1, buf2);
89-
} catch {}
90-
}
91-
return false;
84+
if (username === ADMIN_ROUTES_USERNAME) {
85+
try {
86+
const buf1 = Buffer.from(password.padEnd(100));
87+
const buf2 = Buffer.from(ADMIN_ROUTES_PASSWORD.padEnd(100));
88+
return timingSafeEqual(buf1, buf2);
89+
} catch {}
90+
}
91+
return false;
9292
};

0 commit comments

Comments
 (0)