Skip to content

Commit

Permalink
Extend your API
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Ho authored and gunjpan committed Dec 24, 2015
1 parent eb9a0f4 commit 0a4d3ac
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions common/models/coffee-shop.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
module.exports = function(CoffeeShop) {
CoffeeShop.status = function(cb) {
var currentDate = new Date();
var currentHour = currentDate.getHours();
var OPEN_HOUR = 6;
var CLOSE_HOUR = 20;

console.log('Current hour is ' + currentHour);

var response;
if (currentHour > OPEN_HOUR && currentHour < CLOSE_HOUR) {
response = 'We are open for business.';
} else {
response = 'Sorry, we are closed. Open daily from 6am to 8pm.';
}
cb(null, response);
};

CoffeeShop.remoteMethod(
'status',
{
http: {path: '/status', verb: 'get'},
returns: {arg: 'status', type: 'string'}
}
);
};

0 comments on commit 0a4d3ac

Please sign in to comment.