Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7
Plugin to share a common GunDB connection across Fastify 🔫
License
NotificationsYou must be signed in to change notification settings
lmangani/fastify-gundb
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
FastifyGunDB connection plugin, with this you can share a Gun instance in every part of your server.
npm i fastify-gundb --save
Add it to you project withregister
and you are done!
You can access Gun viafastify.gun
.
constfastify=require('fastify')fastify.register(require('fastify-gundb'),{name:'db'},err=>{if(err)throwerr})fastify.get('/foo',(req,reply)=>{const{ gun}=fastify.gungun.get(req.query.key).once(function(val){if(!val)val={status:404}reply.send(val)})})fastify.post('/foo',(req,reply)=>{const{ gun}=fastify.gungun.get(req.body.key).put(req.body.value,(ack)=>{if(!ack)val={status:'error'}reply.send({status:'ok'})})})fastify.listen(3000,err=>{if(err)throwerrconsole.log(`server listening on${fastify.server.address().port}`)})
This project is kindly sponsored by:
Fastify is kindly sponsored by:
Licensed underMIT.
About
Plugin to share a common GunDB connection across Fastify 🔫
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.