cloudant-envoy
Advanced tools
Comparing version 0.2.4 to 0.2.5
24
app.js
@@ -32,13 +32,3 @@ 'use strict'; | ||
// session support | ||
if (opts && opts.sessionHandler) { | ||
app.use(opts.sessionHandler) | ||
} else { | ||
console.log('[OK] Using default session handler'); | ||
app.use(session({ | ||
secret: app.metaKey, | ||
resave: true, | ||
saveUninitialized: true | ||
})); | ||
} | ||
@@ -75,2 +65,14 @@ // Setup the logging format | ||
// session support | ||
if (opts && opts.sessionHandler) { | ||
app.use(opts.sessionHandler) | ||
} else { | ||
console.log('[OK] Using default session handler'); | ||
app.use(session({ | ||
secret: app.metaKey, | ||
resave: true, | ||
saveUninitialized: true | ||
})); | ||
} | ||
// load the routes | ||
@@ -77,0 +79,0 @@ var router = require('./lib/routes/index'); |
@@ -12,2 +12,3 @@ 'use strict'; | ||
databaseName: process.env.ENVOY_DATABASE_NAME || startOpts.databaseName || 'envoy', | ||
usersDatabaseName: process.env.ENVOY_USERS_DATABASE_NAME || startOpts.usersDatabaseName || 'envoyusers', | ||
logFormat: process.env.LOG_FORMAT || startOpts.logFormat || 'off', | ||
@@ -14,0 +15,0 @@ port: process.env.PORT || startOpts.port || 8000, |
@@ -6,6 +6,6 @@ 'use strict'; | ||
uuid = require('uuid'), | ||
USERS_DATABASE_NAME = 'envoyusers', | ||
app = require('../../../app'), | ||
express = require('express'), | ||
router = express.Router(), | ||
dbName = null, | ||
usersdb = null; | ||
@@ -16,15 +16,16 @@ | ||
var init = function(callback) { | ||
usersdb = app.cloudant.db.use(USERS_DATABASE_NAME); | ||
dbName = app.opts.usersDatabaseName; | ||
usersdb = app.cloudant.db.use(dbName); | ||
app.cloudant.db.get(USERS_DATABASE_NAME, function(err, body, header) { | ||
app.cloudant.db.get(dbName, function(err, body, header) { | ||
if ((err && err.statusCode === 404)) { | ||
// 404 response == DB doesn't exist, try to create it | ||
app.cloudant.db.create(USERS_DATABASE_NAME, function(err, body, header) { | ||
app.cloudant.db.create(dbName, function(err, body, header) { | ||
if (err && err.statusCode !== 412) { | ||
// 412 response == already exists, maybe the DB got created between checking and creating? | ||
// any other error response, bail out | ||
return callback(err, '[ERR] createUsersDB: please log into your CouchDB Dashboard and create a new database called ' + USERS_DATABASE_NAME + "."); | ||
return callback(err, '[ERR] createUsersDB: please log into your CouchDB Dashboard and create a new database called ' + dbName + "."); | ||
} else if (!err && header.statusCode === 201) { | ||
// 201 response == created, we can start | ||
callback(null, '[OK] Created users database: ' + USERS_DATABASE_NAME); | ||
callback(null, '[OK] Created users database: ' + dbName); | ||
} | ||
@@ -34,6 +35,6 @@ }); | ||
// 403 response == something's up with permissions | ||
return callback(err, '[ERR] createUsersDB: please ensure API key and/or database permissions are correct for ' + USERS_DATABASE_NAME + " (403 Forbidden).") | ||
return callback(err, '[ERR] createUsersDB: please ensure API key and/or database permissions are correct for ' + dbName + " (403 Forbidden).") | ||
} else if (!err && header.statusCode === 200) { | ||
// 200 response == database found, we can start | ||
callback(null, '[OK] Users database already exists: ' + USERS_DATABASE_NAME); | ||
callback(null, '[OK] Users database already exists: ' + dbName); | ||
} | ||
@@ -40,0 +41,0 @@ }); |
{ | ||
"name": "cloudant-envoy", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "A mobile backend shim to Cloudant", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -91,2 +91,3 @@ # Cloudant Envoy (beta) | ||
* ENVOY_STATIC - when set to a full path, this directory is served out as static content from the Envoy express app. | ||
* ENVOY_USERS_DATABASE_NAME - the name of the database to store users when using the `default` auth plugin. Defaults to `envoyusers`. | ||
@@ -253,3 +254,3 @@ ## Using Envoy in your own app | ||
The `default` auth plugin uses the `envoyusers` database to store a database of users who are allowed to authenticate. Add a user to your `envoyusers` database with a document like this: | ||
The `default` auth plugin uses the `envoyusers` database (by default) to store a database of users who are allowed to authenticate. Add a user to your `envoyusers` database with a document like this: | ||
@@ -256,0 +257,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
348326
4297
303
53