arb / celebrate

A joi validation middleware for Express.
MIT License
1.34k stars 65 forks source link

joi upgrade #109

Closed arb closed 5 years ago

arb commented 5 years ago

upgrade to @hapi/joi which is version 15.

Zophiel commented 5 years ago

@arb I've updated the npm package to use @hapi/joi but i keep getting an AssertionError that's calling all kinds of methods or variables is not allowed.

Any idea's?

arb commented 5 years ago

I've got this working locally. Had a flight to SF so I worked on it on the plane.

Zophiel commented 5 years ago

.. so whats the solution? :P

arb commented 5 years ago

I'm not sure exactly what problem you're having but I had to go through and change all the require statements to require('@hapi/joi')

Zophiel commented 5 years ago

I did the same thing, npm i @hapi/joi -s and uninstalled joi. Changed joi -> @hapi/joi. Getting an assert error on all kinds of _isJoi methods on line 79 in index.js.

Zophiel commented 5 years ago

@arb Here is the stack trace:

(node:8137) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: ifError got unwanted exception: "isJoi" is not allowed. "_currentJoi" is not allowed. "_type" is not allowed. "_settings" is not allowed. "_baseType" is not allowed. "_valids" is not allowed. "_invalids" is not allowed. "_tests" is not allowed. "_refs" is not allowed. "_flags" is not allowed. "_description" is not allowed. "_unit" is not allowed. "_notes" is not allowed. "_tags" is not allowed. "_examples" is not allowed. "_meta" is not allowed. "_inner" is not allowed at celebrate (/Users/kevintoet/Work/unit-api/node_modules/celebrate/lib/index.js:79:10) at Object.exports.process (/Users/kevintoet/Work/unit-api/node_modules/joi/lib/errors.js:203:19) at internals.Object._validateWithOptions (/Users/kevintoet/Work/unit-api/node_modules/joi/lib/types/any/index.js:764:31) at module.exports.internals.Any.root.validate (/Users/kevintoet/Work/unit-api/node_modules/joi/lib/index.js:147:23) at celebrate (/Users/kevintoet/Work/unit-api/node_modules/celebrate/lib/index.js:78:20) at Object.<anonymous> (/Users/kevintoet/Work/unit-api/app/routes.js:31:5) at Module._compile (internal/modules/cjs/loader.js:721:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10) at Module.load (internal/modules/cjs/loader.js:620:32) at tryModuleLoad (internal/modules/cjs/loader.js:560:12) at Function.Module._load (internal/modules/cjs/loader.js:552:3) at Module.require (internal/modules/cjs/loader.js:657:17) at require (internal/modules/cjs/helpers.js:22:18) at start (/Users/kevintoet/Work/unit-api/server.js:13:22) at internalTickCallback (internal/process/next_tick.js:77:7) at process._tickCallback (internal/process/next_tick.js:47:5) at Function.Module.runMain (internal/modules/cjs/loader.js:777:11) at executeUserCode (internal/bootstrap/node.js:342:17) at startExecution (internal/bootstrap/node.js:276:5) at startup (internal/bootstrap/node.js:227:5) at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) (node:8137) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:8137) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:8137) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.

arb commented 5 years ago

I'm not really sure what issue you are having, but check out #111 for the full change set.