-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add nodenext compatiblity #196
Conversation
@@ -5,8 +5,8 @@ const fp = require("fastify-plugin"); | |||
* by setting the relevant response headers. | |||
* @param {object} server - Fastify instance. | |||
*/ | |||
async function plugin(server) { | |||
server.addHook("onRequest", async (req, res) => { | |||
async function fastifyDisablecache(server) { |
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.
renamed the function to reflect how fastifyPlugin would name it.
See:
https://github.com/fastify/fastify-plugin/blob/master/lib/toCamelCase.js
async function plugin(server) { | ||
server.addHook("onRequest", async (req, res) => { | ||
async function fastifyDisablecache(server) { | ||
server.addHook("onRequest", async (_req, res) => { |
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.
non necessary change, basically _ indicates parameters not used. But not relevant to this PR.
name: "fastify-disablecache" | ||
} | ||
); | ||
module.exports.default = fastifyDisablecache; |
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.
fastifyPlugin is mutating the function itself. so you can just reassign after called fastifyPlugin once.
I usually tried to keep the order of module.exports, then module.exports.default and last module.exports.fastifyPluginName
We could have added unit tests to ensure that the exports are set correctly and typings tests. |
Thank you so much for this @Uzlopak! Didn't expect you to make a PR, but definitely makes it much easier for me to understand! |
The nodenext compatibilty is actually based on
fastify/fastify#4349