heres the git hub repo
the error message is
Keys
[your_program] [ 'apple' ]
[your_program] KEYS * Response: *1
[your_program] $5
[your_program] apple
[your_program]
[tester::#JW4] Received: "*1\r\n$2\r\napple,apple\r\n*1\r\n$5\r\na"
[tester::#JW4] ^ error
[tester::#JW4] Error: Expected \r\n after 2 bytes of data in bulk string
[tester::#JW4] Test failed
the code block
if (commands[2] === "KEYS" && commands[4] === "*") {
console.log("******** Handling KEYS * Command ********");
// Get all keys, excluding config entries
const keys = Array.from(dataStore.keys()).filter(
(key) => key !== "dir" && key !== "dbfilename"
);
console.log("Keys");
console.log(keys);
let response = `*${keys.length}\r\n`; // RESP array of keys
keys.forEach((key) => {
// Properly format each key as a bulk string
console.log("Key are");
console.log(key);
response += `$${key.length}\r\n${key}\r\n`; // Each key is a bulk string
console.log("Key: " + key);
});
console.log("KEYS * Response:", response);
connection.write(response); // Send the response to the connection
}
}