Skip to content

Commit f041ccf

Browse files
author
EC2 Default User
committed
Add timer start function
1 parent 64e7756 commit f041ccf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ app.post('/api/timers/start', function(req, res) {
4141
});
4242
});
4343

44+
app.post('/api/timers/stop', function(req, res) {
45+
Timer.findOne({id: req.body.id}, function(err, foundTimer) {
46+
if (err) {
47+
console.log(err);
48+
} else {
49+
foundTimer.elapsedTime += req.body.stopTime - foundTimer.startedFrom;
50+
foundTimer.startedFrom = null;
51+
foundTimer.save(function(err) {
52+
console.log(err);
53+
});
54+
}
55+
});
56+
});
57+
4458
app.listen(process.env.PORT, process.env.IP, function() {
4559
console.log('Server started at: ', process.env.IP + ':' + process.env.PORT);
4660
})

0 commit comments

Comments
 (0)