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'); |
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 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
// Example module | |
import api from './api'; | |
import { | |
FETCH_DATA | |
} from './actions.types.js'; | |
import { | |
FETCH_DATA_START, | |
FETCH_DATA_SUCCESS, | |
FETCH_DATA_FAILURE |
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
// mutations.types.js | |
export const FETCH_DATA_START = "FETCH DATA START"; | |
export const FETCH_DATA_SUCCESS = "FETCH DATA SUCCESS"; | |
export const FETCH_DATA_FAILURE = "FETCH DATA FAILURE"; |
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
// actions.types.js | |
export const FETCH_DATA = "FETCH DATA"; |
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
// What I do | |
export const FETCH_DATA = "FETCH DATA"; | |
// Things other people sometimes do | |
export const fetchData = "fetchData"; | |
export const fetchData = "FETCH_DATA"; | |
export const fetchData = "FETCH DATA"; | |
// and about every combination of camel / underscore casing |
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
npm i -g hygen | |
# Or yarn global add hygen | |
git clone https://github.com/koptionalsoftware/vuex-hygen-templates.git | |
cd vuex-hygen-templates |
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 clearCollection = db => async collections => { | |
await Promise.all( | |
collections.map(async collection => { | |
// get documents | |
const documents = await collection.listDocuments(); | |
await Promise.all( | |
documents.map(async doc => { | |
const collections = await db.doc(`${doc.path}`).listCollections(); | |
// If document has a sub collection delete that first | |
if (collections.length > 0) { |
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
#create an action and some mutations. Use camelCasing for the action! | |
hygen asyncaction new fetchData | |
## The above is equivalent to: | |
# hygen action new fetchData | |
# hygen mutation new fetchDataStart | |
# hygen mutation new fetchDataSuccess | |
# hygen mutation new fetchDataFailure | |
OlderNewer