Permalink
Browse files

Get ENV fixed

  • Loading branch information...
cloudnode
cloudnode committed Oct 1, 2011
1 parent ed6219c commit 1bbbc13cd7c0c38e228a6da1c7c6a97f60ce0893
Showing with 6 additions and 33 deletions.
  1. +2 −2 README.rdoc
  2. +1 −1 app.js
  3. +3 −30 lib/app.js
View
@@ -44,8 +44,8 @@ Please see install.txt for setup instructions (https://github.com/dvbportal/node
/env - delete environment key/value pair (requires basic auth, appname, and environment key)
curl -X DELETE -k -u "testuser:123" -d "appname=test&key=color" https://api.cloudno.de/env
- /env - get environment info (requires basic auth, appname, and environment key)
- curl -k -u "testuser:123" -d "appname=test&key=color" https://api.cloudno.de/env
+ /env - get environment info (requires basic auth, appname)
+ curl -k -u "testuser:123" https://api.cloudno.de/env/appname
NPM
/npm - install, update and uninstall npm packages to your application
View
2 app.js
@@ -129,7 +129,7 @@ myapp.get('/applogs/:appname', middle.authenticate, middle.authenticate_app, app
// curl -u GET -u "testuser:123" -d "appname=test" http://localhost:4001/env
// curl -u PUT -u "testuser:123" -d "appname=test&key=NODE_ENV&value=production" http://localhost:4001/env
// curl -u DELETE -u "testuser:123" -d "appname=test&key=NODE_ENV" http://localhost:4001/env
-myapp.get('/env', middle.authenticate, middle.authenticate_app, app.env_get);
+myapp.get('/env/:appname', middle.authenticate, middle.authenticate_app, app.env_get);
myapp.put('/env', middle.authenticate, middle.authenticate_app, app.env_put);
myapp.delete('/env', middle.authenticate, middle.authenticate_app, app.env_delete);
View
@@ -370,36 +370,9 @@ module.exports = {
});
},
env_get: function(req, res, next) {
- var appname = req.body.appname.toLowerCase();
- var db = lib.get_couchdb_database('apps');
- db.get(appname, function(err, appdoc) {
- if (err) {
- res.writeHead(500, {
- 'Content-Type': 'application/json'
- });
- res.end(JSON.stringify({
- status: "failure",
- message: err.error + ' - ' + err.reason
- }) + '\n');
- } else {
- var start = req.body.start;
- db.get(appname, function(err, doc) {
- if (err) {
- res.writeHead(500, {
- 'Content-Type': 'application/json'
- });
- res.end(JSON.stringify({
- status: "failure",
- message: err.error + ' - ' + err.reason
- }) + '\n');
- } else {
- res.send({
- status: "success",
- message: doc.env || {}
- });
- }
- });
- }
+ res.send({
+ status: "success",
+ message: req.app.env || {}
});
},
env_put: function(req, res, next) {

1 comment on commit 1bbbc13

Owner

dvbportal commented on 1bbbc13 Oct 1, 2011

This fixes the GET ENV API call and makes it consistent with other GET calls.

Please sign in to comment.