Skip to content

Commit 7bc3f22

Browse files
MattCollins84glynnbird
authored andcommitted
Change the requirements for running locally to make it simpler (#41)
1 parent 2072be3 commit 7bc3f22

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ The fastest way to deploy this application to Bluemix is to click the **Deploy t
4242

4343
Clone this repository then run `npm install` to add the Node.js libraries required to run the app.
4444

45-
Then create an environment variable that mimics Cloud Foundry e.g.
45+
Then create an environment variable that store your Cloudant URL:
4646

4747
```sh
48-
export VCAP_SERVICES='{"cloudantNoSQLDB":[{"name":"simple-search-service-cloudant-service","label":"cloudantNoSQLDB","plan":"Shared","credentials":{"username":"USERNAME","password":"PASSWORD","host":"HOSTNAME","port":443,"url":"https://USERNAME:PASSWORD@HOSTNAME"}}]}'
48+
export SSS_URL='https://USERNAME:PASSWORD@HOSTNAME'
4949
```
5050

5151
replacing the `USERNAME`, `PASSWORD` and `HOSTNAME` placeholders for your own Cloudant account's details.

lib/credentials.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
1-
var services = process.env.VCAP_SERVICES;
2-
if (typeof services != 'undefined') {
3-
services = JSON.parse(services);
1+
// If the Bluemix VCAP_SERVICES env variable is there
2+
// Use this to load credentials
3+
if (typeof process.env.VCAP_SERVICES !== 'undefined') {
4+
var services = process.env.VCAP_SERVICES;
5+
if (typeof services != 'undefined') {
6+
services = JSON.parse(services);
7+
}
48
}
9+
10+
// Otherwise, look for the SSS_URL env variable
11+
// Build credentials object from that
12+
else if (typeof process.env.SSS_URL !== 'undefined') {
13+
var services = {
14+
cloudantNoSQLDB: [
15+
{
16+
credentials: {
17+
url: process.env.SSS_URL
18+
}
19+
}
20+
]
21+
}
22+
}
23+
24+
// If we can't find any credentials
25+
// Throw error and die
26+
else {
27+
throw new Error("Cloudant credentials not found");
28+
}
29+
530
module.exports = services;

0 commit comments

Comments
 (0)