Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@koptionalsoftware
Last active November 5, 2018 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koptionalsoftware/95eb151a63ee1a6a8d19f0f2defc375a to your computer and use it in GitHub Desktop.
Save koptionalsoftware/95eb151a63ee1a6a8d19f0f2defc375a to your computer and use it in GitHub Desktop.
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