-
Notifications
You must be signed in to change notification settings - Fork 11
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
Cache #31
Cache #31
Conversation
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 you please add a test?
I considered that, but then I figured that if we have 100 on tap it means that the cache is already tested. If we want to test it explicitly instead, we may need to extract it so that it can be provided as a plugin option (can't think of any other way to test it directly). It's probably easy to do but it modifies the plugin interface so it also has to be documented. wdyt? |
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
this is ok, no worries |
here is my concern about your cache implementation. You can test the caches by specify two different route level serializer with same type but different behavior. and compare the expected result. if the serialized results are the same the test should fail because it break the route level serializer usage. Another test that needed is, specify a route level serializer for an accepted type that global serializer do not have. then trigger the route once and trigger another route that do not have the route level serializer. if it do not throw an error, it means the caches is polluted by the route level config. |
I would agree with @climba03003 , but... the custom configuration per route is documented but not implemented! This snippet doesn't work:
While, registering the plugin like this works as expected:
The tests confirm this: fastify-accepts-serializer/test/test.js Line 255 in c1df293
Opening a new issue about it |
@Eomm @climba03003 does this PR need further work? |
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
Fixes #30
Not an extremely elegant solution, but minimal code changes to make the cache work.
Checklist
npm run test
andnpm run benchmark
and the Code of conduct