REST API response format based on some of the best practices
This file contains hidden or 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
{ | |
// http://eslint.org/docs/rules/ | |
"ecmaFeatures": { | |
"binaryLiterals": false, // enable binary literals | |
"blockBindings": false, // enable let and const (aka block bindings) | |
"defaultParams": false, // enable default function parameters | |
"forOf": false, // enable for-of loops | |
"generators": false, // enable generators | |
"objectLiteralComputedProperties": false, // enable computed object literal property names |
This file contains hidden or 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
// Native selectors. | |
(function(window, document) { | |
'use strict'; | |
var noop = function() { | |
}; | |
// DOCUMENT LOAD EVENTS | |
// not needed at the bottom of the page | |
document.addEventListener('DOMContentLoaded', noop); |
This file contains hidden or 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
// snippet taken from http://catapulty.tumblr.com/post/8303749793/heroku-and-node-js-how-to-get-the-client-ip-address | |
function getClientIp(req) { | |
var ipAddress; | |
// The request may be forwarded from local web server. | |
var forwardedIpsStr = req.header('x-forwarded-for'); | |
if (forwardedIpsStr) { | |
// 'x-forwarded-for' header may return multiple IP addresses in | |
// the format: "client IP, proxy 1 IP, proxy 2 IP" so take the | |
// the first one | |
var forwardedIps = forwardedIpsStr.split(','); |
This file contains hidden or 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
export function localstorageMeta (key: string, reducer: any): any { | |
return function(state: any, action: any): any { | |
let nextState = reducer(state, action); | |
let storageState = JSON.parse(localStorage.getItem(key)); | |
if (action.type === RESET_STATE || action.type.includes('DELETE')) { | |
localStorage.removeItem(key); | |
} else if (!state && storageState || action.type === '@@redux/INIT') { | |
nextState = storageState; | |
} else if (nextState && nextState !== storageState) { |
This file contains hidden or 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 Promise = require('bluebird'); | |
const React = require('react'); | |
const superagent = require('superagent'); | |
const assign = require('lodash/object/assign'); | |
const isArray = require('lodash/lang/isArray'); | |
const isFunction = require('lodash/lang/isFunction'); | |
const isObject = require('lodash/lang/isArray'); | |
const isString = require('lodash/lang/isString'); | |
const log = require('debug')('component:await'); |
This file contains hidden or 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
import FileService from './FileService' | |
import PDFService from './PDFService' | |
const SERVICE_PDF_URL = process.env.SERVICE_PDF_URL | |
export const getTemplateData = async (id, headers) => { | |
try { | |
// Preparte data for you template | |
return { } | |
} catch (err) { |
This file contains hidden or 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 AWS = require('aws-sdk'); | |
const ssm = new AWS.SSM(); | |
const getParameterFromSystemManager = async (key, isEncrypted = true) => { | |
// Fetches a parameter from SSM parameter store. | |
// Requires a policy for SSM:GetParameter on the parameter being read. | |
const params = { | |
Name: key, |
This file contains hidden or 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 _ = require('lodash'); | |
const Busboy = require('busboy'); | |
const getContentType = (event) => { | |
// Serverless offline is passing 'Content-Type', AWS is passing 'content-type' | |
let contentType = _.get(event, 'headers.content-type'); | |
if (!contentType) contentType = _.get(event, 'headers.Content-Type'); | |
return contentType; | |
}; |
OlderNewer