Gathering detailed insights and metrics for @therockhopper/connect-cloudant-store
Gathering detailed insights and metrics for @therockhopper/connect-cloudant-store
Gathering detailed insights and metrics for @therockhopper/connect-cloudant-store
Gathering detailed insights and metrics for @therockhopper/connect-cloudant-store
npm install @therockhopper/connect-cloudant-store
Typescript
Module System
Node Version
NPM Version
65.9
Supply Chain
90.9
Quality
69.5
Maintenance
50
Vulnerability
97.6
License
JavaScript (100%)
Total Downloads
1,656
Last Day
1
Last Week
6
Last Month
25
Last Year
289
1 Stars
19 Commits
11 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
@therockhopper/connect-cloudant-store@1.0.1
Unpacked Size
39.91 kB
Size
8.32 kB
File Count
8
NPM Version
7.4.3
Node Version
15.7.0
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
20%
6
Compared to previous week
Last month
733.3%
25
Compared to previous month
Last year
-19%
289
Compared to previous year
NodeJS express-session storage connector for IBM Cloudant. The module is build on top of the cloudant npm module with promises plugin - the official Node JS Cloudant library.
npm install connect-cloudant-store
Using the CloudantStore express-session storage:
1 2var session = require('express-session'); 3var CloudantStore = require('connect-cloudant-store')(session); 4// example for local instance of cloudant - required params 5// database 'sessions' needs to be created prior to usage 6var store = new CloudantStore( 7 { 8 url: 'https://MYUSERNAME:MYPASSWORD@MYACCOUNT.cloudant.com' 9 } 10); 11 12store.on('connect', function() { 13 // Cloudant Session store is ready for use 14}); 15 16store.on('disconnect', function() { 17 // failed to connect to cloudant db - by default falls back to MemoryStore 18}); 19 20store.on('error', function(err) { 21 // You can log the store errors to your app log 22}); 23 24app.use(session({ 25 store: store, 26 secret: 'keyboard cat' 27}));
Standard usage for Bluemix (public) environment :
1var store = new CloudantStore( 2 { 3 instanceName: 'myCloudantServiceName', 4 vcapServices: JSON.parse(process.env.VCAP_SERVICES) 5 } 6); 7 8app.use(session({ 9 store: store, 10 secret: 'keyboard cat' 11}));
The storage class has a auto-clean specific method that has to be called in your code. It could be trigger for example from a setIterval timer. It checks if there is already a view available for getting the expired sessions from store db, and if not, is trying to create it. There are related optional parameters to customize the name of the view/design, set a top limit for items deleted per cleanup call.
1store.on('connect', function() { 2 // set cleanup job every other hour 3 setInterval(function() { store.cleanupExpired(); }, 3600 * 1000); 4});
Bellow is an example of creating an instance with the full list of parameters (default values highlighted):
1var store = new CloudantStore({ 2 // connector specific parameters 3 client: null, // new Cloudant(options) 4 database: 'sessions', 5 prefix: 'sess', 6 ttl: 86400, 7 disableTTLRefresh: false, 8 dbViewName: 'express_expired_sessions', 9 dbDesignName: 'expired_sessions', 10 dbRemoveExpMax: 100, 11 // Cloudant() parameters used if 'client' is not provided 12 url: undefined, 13 instanceName: undefined, 14 vcapServices: undefined, 15 } 16); 17
Allows to create the Cloudant client based on the url (containing credentials)
ex:
https://MYUSERNAME:MYPASSWORD@MYACCOUNT.cloudant.com
Can be used for working on a dev environment (ex: docker cloudant-developer)
http://MYUSERNAME:MYPASSWORD@LOCALIP:LOCALPORT
Allows to create the Cloudant client based on vcapServices JSON entry for your application and the name of the instance.
See: https://github.com/cloudant/nodejs-cloudant#initialization
Note: This will not work on Bluemix Dedicated because cloudant library is not searching by service name first, but instead by service type key first and second by service name (instanceName);
You can use directly a cfenv npm module to get a working Cloudant url by service name:
1var svc = require('cfenv').getAppEnv().getServiceCreds('myCloudantServiceName'); 2if (svc) { 3 store = new CloudantStore( 4 { 5 url: svc.url 6 } 7 ); 8}
Offers the mechanism to inject an instance of Cloudant() module as the client -> replaces any of the Cloudant parameters above
session/storage time to live - overrides the session cookie maxAge value if present
Custom prefix to be appended for all session keys
Set a different database as the session database - needs to be created prior to the connector usage.
Disable the session storage TTL automatical refresh by disabling the "touch" method, in order to reduce the number of requests to Cloudant and the risk of conflicts. As a result the session will have a fixed duration from creation (of either the .ttl param or of the session.cookie.maxAge)
Name of the expired session view to be used for building the expired sessions list
Name of the couch db design name to be used for building the expired sessions list - if the design and the view is not found in the cloudant database, the first call to store.cleanupExpired() will try to create it.
Limits the maximum amount of sessions to be bulk deleted per each store.cleanupExpired() call.
Local development
1export DEBUG=connect:cloudant-store 2# then run your Node.js application 3npm start
For Bluemix - use the manifest.yml file to inject the ENV variable:
1# ... 2env: 3 DEBUG: connect:cloudant-store 4 services: 5 - my-cloudant-service
PR code needs to pass the eslint check and unit test
npm test
PR code should have UT associated with a good coverage
npm run coverage
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
no SAST tool detected
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
60 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More