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 DynamoDB = { | |
DocumentClient() { | |
return { get: params => ({ promise: async () => params }) }; | |
}, | |
}; | |
const ddb = new DynamoDB.DocumentClient({ region: 'eu-west-1' }); | |
export async function handleV2(event) { // eslint-disable-line import/prefer-default-export | |
const { TableName, Key } = event; |
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
var utils = require('lazy-cache')(require); | |
var fn = require; | |
require = utils; | |
require('x', 'y'); |
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 webpack = require('webpack'); | |
module.exports = { | |
// ... your webpack configuration ... | |
plugins: [ | |
new webpack.ContextReplacementPlugin( | |
/\/package-name\//, | |
(data) => { | |
delete data.dependencies[0].critical; | |
return data; |
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 AWS from 'aws-sdk'; | |
const s3 = new AWS.S3({ | |
httpOptions: { | |
connectTimeout: 2 * 1000, // time succeed in starting the call | |
timeout: 5 * 1000, // time to wait for a response | |
// the aws-sdk defaults to automatically retrying if either of these limits are met. | |
}, | |
}); | |
// use S3 happily! |
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
#!/usr/bin/env node | |
/* eslint-disable no-console */ | |
const path = require('path'); | |
const fs = require('fs'); | |
const templateFile = path.join(__dirname, '../../serverless.templates.yml'); | |
const projectFile = path.join(__dirname, '../../serverless.project.yml'); | |
const profileFile = path.join(__dirname, `../../serverless.project.${process.env.AWS_PROFILE}.yml`); | |
const slsFile = path.join(__dirname, '../../serverless.yml'); |
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 util from 'util'; | |
import AWS from 'aws-sdk'; | |
// command options | |
const OPT_NAME = 'my-first-dashboard'; // name of dashboard to sync. | |
const OPT_TEMPLATE = 'master'; // environment to sync-from. | |
// dashboard/environment options | |
const asName = (name, environment) => `${name}-${environment}`; // template for full dashboard name. | |
const environments = ['master', 'staging', 'production']; // environments to duplicate across |
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
// ensures all aws-sdk calls are based on a singleton, captured using the singleton xray-sdk. | |
import aws from 'aws-sdk'; | |
import { captureAWS } from 'aws-xray-sdk'; | |
const captured = captureAWS(aws); | |
export default captured; |
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 AWS from 'aws-sdk'; | |
import { captureAWS } from 'aws-xray-sdk'; | |
const captured = captureAWS(AWS); | |
const s3 = new captured.S3(); |
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
/* eslint-env mocha */ | |
/* eslint-disable no-unused-expressions */ | |
import { expect, use } from 'chai'; // eslint-disable-line import/no-named-default | |
import sinon from 'sinon'; | |
import sinonChai from 'sinon-chai'; | |
/* directory structure: | |
/tests/post.spec.js // this test. | |
/src/post.js // the module to test. | |
/adapters/mailer/js // a mail-out adapter. | |
*/ |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"logs:CreateLogGroup", | |
"logs:CreateLogStream", | |
"logs:PutLogEvents" | |
], |