Fastify ArangoDB plugin, with this you can share the same arangodb instance pool in every part of your server.
Under the hood the official arangojs driver is used, the options that you pass to register
will be passed to the ArangoDB client. Passing an object to options is required.
npm i fastify-arangodb --save
Add it to you project with register
and you are done!
You can access the Arango instance via fastify.arango
const fastify = require("fastify")();
fastify.register(require("fastify-arangodb"), {
url: "http://root:root@localhost:8529",
database: "auth"
});
fastify.get("/user/:id", async (req, reply) => {
const collection = fastify.arango.collection("users");
collection.document(req.params.id).then(user => {
reply.send(user);
});
});
fastify.listen(3000, function() {
fasitfy.log(`server listening on ${fastify.server.address().port}`);
});
Licensed under ISC.