Installations
npm install @therockhopper/connect-cloudant-store
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
15.7.0
NPM Version
7.4.3
Score
65.9
Supply Chain
90.9
Quality
69.5
Maintenance
50
Vulnerability
97.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
frankschmidt902
Download Statistics
Total Downloads
1,656
Last Day
1
Last Week
6
Last Month
25
Last Year
289
GitHub Statistics
1 Stars
19 Commits
11 Branches
1 Contributors
Bundle Size
951.74 kB
Minified
263.29 kB
Minified + Gzipped
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
1,656
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
connect-cloudant-store
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.
Setup
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}));
Using the session auto-clean feature
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});
Store Parameters
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
Parameters
url
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
vcapServices && instanceName
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}
client
Offers the mechanism to inject an instance of Cloudant() module as the client -> replaces any of the Cloudant parameters above
ttl
session/storage time to live - overrides the session cookie maxAge value if present
prefix
Custom prefix to be appended for all session keys
database
Set a different database as the session database - needs to be created prior to the connector usage.
disableTTLRefresh
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)
dbViewName
Name of the expired session view to be used for building the expired sessions list
dbDesignName
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.
dbRemoveExpMax
Limits the maximum amount of sessions to be bulk deleted per each store.cleanupExpired() call.
Debugging
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
Contributing
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
Resources
- https://cloudant.com/
- https://console.ng.bluemix.net/catalog/services/cloudant-nosql-db/
- https://github.com/cloudant/nodejs-cloudant
- https://www.npmjs.com/package/express-session
- https://hub.docker.com/r/ibmcom/cloudant-developer/
Attributions
- The connect-cloudant-store code is inspired from from other express-session storage libraries as: connect-redis.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
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
- Warn: no pull requests merged into dev branch
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
60 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-9j49-mfvp-vmhm
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-pc5p-h8pf-mvwp
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-jg8v-48h5-wgxg
- Warn: Project is vulnerable to: GHSA-36fh-84j7-cv5h
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-6xwr-q98w-rvg7
- Warn: Project is vulnerable to: GHSA-4c7m-wxvm-r7gc
- Warn: Project is vulnerable to: GHSA-pch5-whg9-qr2r
- Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4
- Warn: Project is vulnerable to: GHSA-4p35-cfcx-8653
- Warn: Project is vulnerable to: GHSA-7f3x-x4pr-wqhj
- Warn: Project is vulnerable to: GHSA-jpp7-7chh-cf67
- Warn: Project is vulnerable to: GHSA-q6wq-5p59-983w
- Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2
- Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-hpqj-7cj6-hfj8
- Warn: Project is vulnerable to: GHSA-4vrv-93c7-m92j
- Warn: Project is vulnerable to: GHSA-4x6g-3cmx-w76r
- Warn: Project is vulnerable to: GHSA-qqqw-gm93-qf6m
- Warn: Project is vulnerable to: GHSA-69f9-h8f9-7vjf
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
1.7
/10
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