aboutsummaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-07-02 10:35:31 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-07-02 10:35:31 +0200
commit7d5116f6f6096a9f37c4c71635dc570b7048c992 (patch)
treee96ac4954a05660cf8e3ff70eb1d65417ab31ad7 /app.js
parentf895dfeb979f1a98ea38a6a88f99ff63422d4348 (diff)
downloadexample-collection-json-db-7d5116f6f6096a9f37c4c71635dc570b7048c992.tar.gz
example-collection-json-db-7d5116f6f6096a9f37c4c71635dc570b7048c992.tar.bz2
example-collection-json-db-7d5116f6f6096a9f37c4c71635dc570b7048c992.tar.xz
example-collection-json-db-7d5116f6f6096a9f37c4c71635dc570b7048c992.zip
o Adding support for employee name query.
Diffstat (limited to 'app.js')
-rw-r--r--app.js30
1 files changed, 23 insertions, 7 deletions
diff --git a/app.js b/app.js
index 6f3f4cf..dcbfb95 100644
--- a/app.js
+++ b/app.js
@@ -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;