With v5.0.0-beta-1 I get:
TypeError: restify.bodyParser is not a function
Works perfectly with v4.1.1 still.
Hello, as of 5.x the plugins have been moved into a stand alone module, restify-plugins.
Thanks. No documentation states this though (that is the README page which contains installation instructions).
The Server section contains:
server.use(restify.bodyParser());
The Installation section says:
$ npm install restify
This will have to indicate that the plugins must be installed as well. These [incomplete] installation instructions land up on npmjs as well.
Thanks for your quick response.
What is the instructions on dealing with the plugins though ([email protected])? I had to dig in the source now, and seems like if i want to use the bodyParser plugin I must do something like this:
const restifyBodyParser = require('restify-plugins').bodyParser;
server.use(restifyBodyParser());
Is that correct?
What about CORS though, I can see cors.js in the plugins directory, but I don't see it being exported in the index.js file like the other plugins?
What am I missing here?
Apologies - we have to publish new documentation, but that probably won't go out until 5.x is out of beta. In the meantime, your best bet is to reference to 4 to 5 migration guide. That should answer most of your questions.
For the plugins, what you have is right. The plugins exports are documented in the README, otherwise, as you've discovered, the main exports file is a fine place to look as well.
Thanks @DonutEspresso. I appreciate your quick response.
Thank you for the restify 4.x to 5.x migration guide that helps a lot. That also clears up my CORS concern I had before.
For now will stick with v4.1.1 but will move over to latest version as soon as the CORS changes are released on npmjs as well.
Thanks again for your quick responses.
Sure thing - apologies for the noise! We discovered the beta went out untagged, so folks were getting the new versions unknowingly.
Most helpful comment
What is the instructions on dealing with the plugins though (
[email protected])? I had to dig in the source now, and seems like if i want to use thebodyParserplugin I must do something like this:Is that correct?
What about CORS though, I can see
cors.jsin thepluginsdirectory, but I don't see it being exported in theindex.jsfile like the other plugins?What am I missing here?