Skip to content

Instantly share code, notes, and snippets.

Avatar

koptionalsoftware

View GitHub Profile
View middleware.js
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
}
View parse-router-example.js
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});
View express-snippet.js
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');
You can’t perform that action at this time.