Skip to content

Commit

Permalink
v0.10.8
Browse files Browse the repository at this point in the history
+ New Utils Controller
+ Moved isset() into the Util Controller
  • Loading branch information
adamhalasz committed Jun 14, 2016
1 parent e1c6f87 commit e832859
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## v0.10.8 ** - 2016 June 13
- Upgrade `diet-qs` with the new `querystrings` module that fixes nested Query String to Array conversions.
- New Utils Controller
- Moved isset() into the Util Controller

## v0.10.6 ** - 2016 May 10
- Ports are now wildcards for every hostname. Listening on a Port (`app.listen(8000)`) will accept any Hostname request within that Port. Listening on a Hostname (`app2.listen('http://test.com:8000/')`) within that Port will have priority.
Expand Down
4 changes: 2 additions & 2 deletions controllers/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

const url = require('url')
const parent = module.parent.exports

const utils = require('./utils')
// ===========================================================================
// Exports
// ===========================================================================
Expand All @@ -33,7 +33,7 @@
} else if(typeof location == 'object') {
app.location = location;

} else if(!isset(location)){
} else if(!utils.isset(location)){
app.location = url.parse(protocolName+'://0.0.0.0:80/');
}

Expand Down
3 changes: 2 additions & 1 deletion controllers/protocols/http/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
const Error = require('../../error')
const url = require('url')
const RouteIterator = require('../../iterator')
const utils = require('../../utils')

// ===========================================================================
// Exports
Expand All @@ -30,7 +31,7 @@
var host = request.headers.host ? request.headers.host : '' ;
var location = request.url ? url.parse(request.url) : '' ;
var port = host.split(':')[1] || protocol.globalAgent.defaultPort;
var hostname = isset(port) ? host : host + ':' + protocol.globalAgent.defaultPort ;
var hostname = utils.isset(port) ? host : host + ':' + protocol.globalAgent.defaultPort ;

// get app (host controller) handling this hostname
var app = App.hosts[hostname] || App.hosts[hostname+':'+port] || App.hosts['0.0.0.0:'+port]
Expand Down
9 changes: 5 additions & 4 deletions controllers/protocols/http/signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
// Dependencies
// ===========================================================================

const qs = require('diet-qs')
const qs = require('querystrings')
const fs = require('fs')
const url = require('url')
const status_codes = require('http').STATUS_CODES;
const utils = require('../../utils')

// ===========================================================================
// Exports
Expand Down Expand Up @@ -111,19 +112,19 @@
if(!signal.statusCode) signal.status(200)
signal.header('content-type', 'application/json')
var data = signal.data
if(isset(input)) data = Object.merge(signal.data, input)
if(utils.isset(input)) data = Object.merge(signal.data, input)
data.passed = true
signal.end(data, isLast)
},
failure: function(input, isLast){ // respond with JSON errors
if(!signal.statusCode) signal.status(200)
signal.header('content-type', 'application/json')
if(signal.data.errors) signal.errors = Object.merge(signal.error, signal.data.errors)
if(isset(input)) data = Object.merge(signal.errors, input)
if(utils.isset(input)) data = Object.merge(signal.errors, input)
signal.end({ passed: false, errors: signal.errors }, isLast)
},
jsonString: function(input){
if(isset(input)) signal.data = Object.merge(signal.data, input)
if(utils.isset(input)) signal.data = Object.merge(signal.data, input)
if(!signal.statusCode) signal.status(200)
signal.header('content-type', 'application/json')
return JSON.stringify(signal.data);
Expand Down
3 changes: 3 additions & 0 deletions controllers/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports.isset = function isset(object){
return (object != "undefined" && object != undefined && object != null && object != "" && typeof(object) != 'undefined') ? true : false ;
}

0 comments on commit e832859

Please sign in to comment.