node-service-tools
v0.2.21
Published
Utilities for node services
Downloads
12
Readme
This is package provides utilities for node services as follows :
SQL Client
Example usage:
const {mysqlClient} = require('node-service-tools');
const dbClient = new mysqlClient(sqldbServer, sqldbPort, sqldbUser, sqldbPass);
dbClient.queryDB2('INSERT INTO table SET ?', new_entry)
.then(() => {
// Success
})
.catch(()=>{
// Error handling
})
Redis Client (mostly pub/sub API)
Example usage:
const {redisCache} = require('node-service-tools');
const redisClient = new redisCache({
port: process.env.CACHE_PORT,
host: process.env.CACHE_HOST
});
redisClient.publishToChannel(channel, eventSpec); => Publish to channel
redisClient.subscribeToChannel(channel, callBack); => As name implies
redisClient.unSubscribe(channel); => as name implies
redisClient.channelNumSub(channel); => Get number of subscribers in a channel
Websocket client
Example usage:
const {wsClient} = require('node-service-tools');
const eventClient = new wsClient({eventServer, eventPort, protocol, source: apiRoot, eventApiKey});
eventClient.send(eventSpec);