Skip to content

timmak/fastify-arangodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-arangodb

Greenkeeper badge Build Status

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.

Install

npm i fastify-arangodb --save

Usage

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}`);
});

License

Licensed under ISC.