@livestatedb/server
v1.0.2
Published
LivestateDB API server package that will hook into an http server
Downloads
4
Readme
Using the back-end library
useSubscribe won't work until you pass information about your MongoDB and Redis into a function that opens a web socket and connects everything. Require the module in wherever you instantiate an http server, for example server.js. Feel free to give it a label or to to simply invoke the required-in function with the necessary arguments.
const liveStateDB = require('@livestatedb/server');
liveStateDB(httpServer, databaseInfo);
OR
require('@livestatedb/server')(httpServer, databaseInfo);
The second paramater, databaseInfo, must be an object with two key-value pairs - these are for passing in information about your MongoDB database and Redis, respectively. The values are both objects that contain connection information for each database. See example below.
const databaseInfo =
{
mongoDbOptions:
{
uri: "mongodb+srv://name:[email protected]/?retryWrites=true&w=majority"
},
redisDbOptions:
{
host: 'redis-00000.c00.us-east-0-0.ec2.cloud.redislabs.com',
port: 15711,
password: 'lkajsdf092j3jlsdfmop3jfspdkgpoi',
family: 4
},
}