-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to integrate rate-limit headers for Commands left
component UI
#67
Changes to integrate rate-limit headers for Commands left
component UI
#67
Conversation
…me is returned as response header
bc60e1a
to
268adb2
Compare
Hi @lucifercr07 , could you please review the PR?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests.
response.headers.forEach((value, key) => { | ||
headers[key] = value; | ||
}); | ||
headers['x-ratelimit-remaining'] = 101; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why're we hardcoding this number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a temporary change, I'll remove it. It looks like chrome blocks ceratin response headers to be read by the react app, so I had to hardcode this to test it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed this change and done this corresponding change in playground-mono: https://github.com/DiceDB/playground-mono/pull/41/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setOutput((prevOutput) => [...prevOutput, newOutput, result?.body?.error]); | ||
} | ||
const commandsLeft = result?.headers?.['x-ratelimit-remaining']; | ||
const cleanupTimeLeft = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I have to fix this. waiting on this issue DiceDB/playground-mono#32
added test cases as well @lucifercr07 |
@aasifkhan7 please resolve build issues. |
resolved formatting issues @lucifercr07 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aasifkhan7 shall we just keep changes for commandsLeft
as part of this PR as discussed earlier? Since the PR for cleanup time left is still pending.
Okay, let me do that @lucifercr07 |
Done @lucifercr07 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks fine, but i'm a bit worried about introducing a lot of any
s in the code, please avoid it and use zod
to validate the payload immedately after we get the response.
I'm also not sure why we have both CLI and Shell, we should just have Shell. CLI is not used anymore and is the same thing.
|
||
// Parse the result as JSON | ||
const result = await response.json(); | ||
return result; | ||
const body = await response.json(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have a type defined here? preferrably using zod schema. Idea is to ensure and catch early if there is an issue with the response.
right now, we just have a lot of any
which should be avoided
result: any, | ||
newOutput: string, | ||
setOutput: any, | ||
onCommandExecuted: any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid the any
here? very easy to make mistakes on this. Let me know if you need any help with the actual types
export const handleResult = ( | ||
result: any, | ||
newOutput: string, | ||
setOutput: any, | ||
onCommandExecuted: any, | ||
) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when we have more than 3 arguments, let's convert it into an object, so that we can have named arguments. so instead of hanleResult(result, newOutput, setOutput, onComandExecuted) => hanleResult({ result, newOutput, setOutput, onComandExecuted })
Done all the changes except removing the CLI @KaviiSuri . Please let me know if that also needs to be shipped with this PR as well. |
resolved build failures @KaviiSuri @lucifercr07 , please review now |
@aasifkhan7 can you please fix the failing tests. |
@lucifercr07 fixed the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@aasifkhan7 could you also remove the CLI? looks good otherwise, will merge post that |
removed cli @KaviiSuri |
Commands left
component UI
…setup-ui-packages-and-tailwind-for-console * 'master' of github.com:DiceDB/playground-web: Fix docker compose file (DiceDB#77) integrate cleanup time from playground-mono (DiceDB#76) Changes to integrate rate-limit headers for `Commands left` component UI (DiceDB#67) Adding support for JSON.SET command (DiceDB#74) Unit tests for playground-web repository (DiceDB#71) fix: docker compose contexts to ensure docker compose runs
…setup-ui-packages-and-tailwind-for-console * 'master' of github.com:DiceDB/playground-web: Fix docker compose file (DiceDB#77) integrate cleanup time from playground-mono (DiceDB#76) Changes to integrate rate-limit headers for `Commands left` component UI (DiceDB#67) Adding support for JSON.SET command (DiceDB#74) Unit tests for playground-web repository (DiceDB#71) fix: docker compose contexts to ensure docker compose runs
No description provided.