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 | |
} |
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"); | |
parseRouter.route("posts") | |
.get(async function(req, res){ | |
try { | |
const Post = await new Parse.Query("Post").get(req.params.id, {useMasterKey : true}); | |
res.send(Post) | |
} catch(e) { | |
res.error({message : e.message}); |
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 express = require("express"); | |
const app = express(); | |
/** | |
* See https://expressjs.com/en/guide/routing.html#app-route | |
*/ | |
app.route('/book') | |
.get(function (req, res) { | |
res.send('Get a random book'); |
NewerOlder