Skip to content

Commit fc56dc9

Browse files
author
Matthias Tan
committed
up
1 parent 6593a2f commit fc56dc9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

examples/prompt/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import {
1010
// Define the port to listen on
1111
const PORT = 3000;
1212

13+
// Cache for verification keys to improve performance
14+
let verificationKeysCache = { id: "", keys: [] };
15+
1316
// Define the handler function
1417
async function handler(request, response) {
1518
console.log(`Received [${request.method}] to [${request.url}]`);
@@ -36,15 +39,18 @@ async function handler(request, response) {
3639
const keyID = String(request.headers["github-public-key-identifier"]);
3740

3841
try {
39-
const { isValidRequest, payload } = await verifyAndParseRequest(
42+
const { isValidRequest, payload, cache } = await verifyAndParseRequest(
4043
body,
4144
signature,
4245
keyID,
4346
{
4447
token: tokenForUser,
48+
cache: verificationKeysCache,
4549
},
4650
);
4751

52+
verificationKeysCache = cache;
53+
4854
if (!isValidRequest) {
4955
console.error("Request verification failed");
5056
response.writeHead(401, { "Content-Type": "text/plain" });

0 commit comments

Comments
 (0)