Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mother/socket.io-adapter-mongo

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mother/socket.io-adapter-mongo

socket.io adapter for MongoDB

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by25%
Maintainers
2
Weekly downloads
 
Created
Source

socket.io-adapter-mongo

Build Status

Installing

npm install @mother/socket.io-adapter-mongo --save

How to use

const io = require('socket.io')(3000);
const mongoAdapter = require('@mother/socket.io-adapter-mongo');
io.adapter(mongoAdapter('mongodb://localhost/test'));

or pass an object:

const io = require('socket.io')(3000);
const mongoAdapter = require('@mother/socket.io-adapter-mongo');

io.adapter(mongoAdapter({
	uri: 'mongodb://localhost/test',
	key: 'socket.io',
	mOptions: {
		tls: true
	}
}));

By running socket.io with the socket.io-adapter-mongo adapter you can run multiple socket.io instances in different processes or servers that can all broadcast and emit events to and from each other.

If you need to emit events to socket.io instances from a non-socket.io process, you should use socket.io-emitter.

API

adapter(uri[, opts])

uri is a a mongodb:// uri string

If using this method of calling the adapter, the uri string will used instead of the uri property in the options object.

For a list of options see below.

adapter(opts)

The following options are allowed:

  • uri: mongodb:// uri string this property or the mongoose property are required.
  • key: the name of the key to pub/sub events on as prefix (socket.io)
  • collectionName: the name of the capped collection to be used (socket.io-message-queue)
  • collectionSize: the size of the capped collection to be used, in bytes (1000000) (10mb)
  • mongoose: an existing Mongoose instance that can be used instead of a mongodb:// uri
  • mOptions: options to pass to Mongoose

Notes

The following options are passed to Mongoose by default:

  • useNewUrlParser: true
  • useUnifiedTopology: true

If you want to override these options, just include them in mOptions.

License

MIT

Keywords

FAQs

Package last updated on 27 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc