diff options
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -1,6 +1,7 @@ var express = require('express') , routes = require('./routes') - , http = require('http'); + , http = require('http') + , url = require('url'); var app = express(); @@ -28,18 +29,33 @@ function urlgenerator(req, res, next) { return 'http://' + host + '/'; }, - departments: function(offset) { - return 'http://' + host + '/department/' + (offset ? '?offset=' + offset : ''); + departments: function(query) { + return url.format({ + protocol: 'http', + host: host, + pathname: '/department/', + query: query + }); }, department: function(dept_no) { return 'http://' + host + '/department/' + dept_no; }, - employees_in_department: function(dept_no, offset) { - return 'http://' + host + '/department/' + dept_no + '/employees' + (offset ? '?offset=' + offset : ''); + employees_in_department: function(dept_no, query) { + return url.format({ + protocol: 'http', + host: host, + pathname: '/department/' + dept_no + '/employees', + query: query + }); }, - employees: function(offset) { - return 'http://' + host + '/employee/' + (offset ? '?offset=' + offset : ''); + employees: function(query) { + return url.format({ + protocol: 'http', + host: host, + pathname: '/employee/', + query: query + }); }, employee: function(emp_no) { return 'http://' + host + '/employee/' + emp_no; |