Reputation: 425
I created an ArangoDB Foxx service, and successfully mounted it on some route using Foxx CLI. My service has a dependency which uses randombytes
. When I call the service it returns an error saying `randomBytes is not a function.
For testing purposes I have created another service and just returned typeof require('randombytes')
. And it returned undefined
.
During installation Foxx CLI didn't warn me anything.
Does anyone had such experience?
Upvotes: 0
Views: 85
Reputation: 767
I don't think that Foxx will alert you to missing dependencies, but it is important to make sure they are included in your ZIP package before installing your service/app.
My project is organized like this:
MyProject
|-- foxx
|-- service1
|-- service2
...
I have a package.json
file in the root of the project, as well as in each of the "service" folders. My workflow (make) runs npm install
inside each "service" folder before creating the ZIP archive.
Just make sure to include the node_modules
folder and all should be happy.
Upvotes: 0
Reputation: 669
First, have you defined your randombytes module in your package.json dependencies ?
{
"private": true,
"dependencies": {
"randombytes": "2.1.0"
}
}
Then what about
let randombytes = require('randombytes');
console.log(randomBytes(16));
Actually I just tested ... and it returns "undefined" as well ... so not sure it's a valid module for arango.
It's better to use arango's crypto methods
https://www.arangodb.com/docs/stable/appendix-java-script-modules-crypto.html#genrandomnumbers
Upvotes: 0