JKHeadley / rest-hapi

🚀 A RESTful API generator for Node.js
https://resthapi.com
MIT License
1.19k stars 153 forks source link

2.0.0 Release Notes #230

Closed JKHeadley closed 4 years ago

JKHeadley commented 4 years ago

Summary

rest-hapi v2.0.0 is a major version update that focuses on updating dependencies to improve security. The primary dependency updates include hapi v18->v19, joi v14->v17, and mongoose v4->v5.

Breaking Changes

All of the breaking changes in this release are related to dependency updates. Please see the links above for updates.

Migration Checklist

Node version

Make sure your node version is v12.14.1 or newer, as required by hapi v19. Node v12 is the current LTS and the recommended version of node.

joi Schema Compiler

Hapi v19 requires that you register the joi module used via server.validator. By default rest-hapi registers joi v17 as the schema compiler to validate generated routes.

For custom routes with validation such as:

              validate: {
                payload: {
                  password: Joi.string()
                    .required()
                    .description("The user's new password")
                }
              },

you will need to update the syntax to either wrap your schema with Joi.object():

              validate: {
                payload: Joi.object({
                  password: Joi.string()
                    .required()
                    .description("The user's new password")
                })
              },

or use the rest-hapi joi module available through RestHapi.joi:

              validate: {
                payload: {
                  password: RestHapi.joi.string()
                    .required()
                    .description("The user's new password")
                }
              },

See also the rest-hapi docs.