diff options
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -14,7 +14,7 @@ app.configure(function(){ app.use(express.methodOverride()); app.use(urlgenerator); app.use(app.router); - app.use(express.static(__dirname + '/public')); + app.use(express.static(__dirname + '/public', {maxAge: 60 * 60 * 1000})); }); app.configure('development', function(){ @@ -24,14 +24,22 @@ app.configure('development', function(){ function urlgenerator(req, res, next) { var host = req.headers.host; res.urlgenerator = { - departments: function() { + start: function() { return 'http://' + host + '/'; }, + + departments: function(offset) { + return 'http://' + host + '/department/' + (offset ? '?offset=' + offset : ''); + }, department: function(dept_no) { return 'http://' + host + '/department/' + dept_no; }, - employees_in_department: function(dept_no) { - return 'http://' + host + '/department/' + dept_no + '/employees'; + employees_in_department: function(dept_no, offset) { + return 'http://' + host + '/department/' + dept_no + '/employees' + (offset ? '?offset=' + offset : ''); + }, + + employees: function(offset) { + return 'http://' + host + '/employee/' + (offset ? '?offset=' + offset : ''); }, employee: function(emp_no) { return 'http://' + host + '/employee/' + emp_no; @@ -40,9 +48,11 @@ function urlgenerator(req, res, next) { next(); } -app.get('/', routes.departments); +app.get('/', routes.index); +app.get('/department', routes.departments); app.get('/department/:dept_no', routes.department); app.get('/department/:dept_no/employees', routes.employees_in_department); +app.get('/employee', routes.employees); app.get('/employee/:emp_no', routes.employee); http.createServer(app).listen(app.get('port'), function(){ |