exports.endpoint = (req, res) => {
function activity (name, color) {
return {
status: name,
color,
};
}
const sleeping = activity("sleeping", "black");
const working = activity("coding", "blue");
const eating = activity("eating", "yellow");
const activities = {
8: sleeping,
12: working,
14: eating,
18: working,
20: activity("playing", "purple"),
21: eating,
23: activity("netflix", "red"),
24: sleeping,
};
const now = new Date();
let hour = now.getHours() + (now.getTimezoneOffset() / 60) + 2 + 1;
let doing;
while (!(doing = activities[hour])) {
hour++;
}
const data = Object.assign({
subject: 'right now',
}, doing);
res.end(JSON.stringify(data));
};