Last active
November 5, 2018 18:01
-
-
Save koptionalsoftware/95eb151a63ee1a6a8d19f0f2defc375a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const parseRouter = require("cloudcode-router"); | |
const moment = require("moment"); | |
function MyMiddlewareFunction(req, res) { | |
const hours = moment().utcOffset(60 * 6).hours(); | |
if (hours < 7 || hours > 19) { | |
return res.error({message: "You can only send messages during working hours!"}) | |
} | |
return | |
} | |
parseRouter.protect(MyMiddlewareFunction, protectedRoute => { | |
protectedRoute.route("messages") | |
.post(function(req, res) { | |
// Create message | |
res.send({success : true}); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment