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
initialPartitions = roundUp(( readCapacityUnits / 3,000 ) + ( writeCapacityUnits / 1,000 )) | |
= roundUp((5000 / 3000) + (1000 / 1000)) | |
= 1.667 + 1 | |
= 2.667 | |
= 3 |
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
npm init | |
npm install --save validate.js |
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
let AWS = require('aws-sdk'); | |
const ddb = new AWS.DynamoDB.DocumentClient(); | |
const validate = require("validate.js"); | |
exports.handler = function (event, context, callback) { | |
//validating email and name | |
var constraints = { | |
email: { | |
presence: true, | |
email: true |
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 { execSync } = require('child_process'); | |
const fs = require("fs"); | |
let read = fs.readFileSync('index.js'); //reading myself | |
let code = read.toString(); | |
let requireRegex = /=\s*require\s*\(['\"](.+)['\"]\)/g; | |
let match = requireRegex.exec(code); | |
while (match != null) { |
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
npm install --prefix /tmp <library_name> --save |
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 { execSync } = require('child_process'); | |
let oldRequire = require; | |
require = function(module) { | |
try{ | |
oldRequire.resolve(`/tmp/node_modules/${module}`); | |
}catch(e){ | |
execSync(`npm install --prefix /tmp --save ${module}`); | |
} | |
return oldRequire(`/tmp/node_modules/${module}`); |
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 { execSync } = require('child_process'); | |
let oldRequire = require; | |
require = function(module) { | |
try{ | |
oldRequire.resolve(`/tmp/node_modules/${module}`); | |
}catch(e){ | |
execSync(`npm install --prefix /tmp --save ${module}`); | |
} | |
return oldRequire(`/tmp/node_modules/${module}`); |
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
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "This template creates the stack for project PJ-1-0-0. Generated by Sigma", | |
"Outputs": { | |
"apigcontactuscontactPOST": { | |
"Description": "POST endpoint for resource /contact on API contact_us", | |
"Value": { | |
"Fn::Join": [ | |
"", | |
[ |
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
//Old Fashion 1 - Two callback functions | |
oldFashionOne(function(error){ | |
//handle error | |
},function(data){ | |
//handle data | |
}); | |
//Old Fashion 2 - One callback function with two arguements | |
oldFashionTwo(function(err,data){ | |
if(!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
function task(onSuccess,onError){ | |
//do task | |
if(failed){ | |
onError(error); | |
}else{ | |
onSuccess(data); | |
} | |
} | |
//calling task |