Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Commit

Permalink
Extend your API
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhoibm committed Oct 14, 2016
1 parent 48c247e commit 91b4d67
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions common/models/coffee-shop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
'use strict';

module.exports = function(Coffeeshop) {

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 91b4d67

Please sign in to comment.