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
#!/bin/bash | |
export CONTAINER_NAME="" | |
export DATABASE_NAME="" | |
export BACKUP_LOCATION="/home/ec2-user/backups" | |
export MONGO_USER="" | |
export MONGO_PASSWORD="" | |
export TIMESTAMP=$(date +'%Y%m%d%H%M%S') | |
export DUMP_PATH=/data/${DATABASE_NAME}-backup-${TIMESTAMP} | |
export ZIP_PATH=${DATABASE_NAME}-backup-${TIMESTAMP}.zip |
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 getNextDate = (dateObj, recurringType) => { | |
let pointerTime = dateObj.getTime() | |
const generatedTimes = [] | |
while (pointerTime <= Date.now()) { | |
let pointerDate = new Date(pointerTime) | |
if (recurringType === 'daily') { | |
pointerTime = pointerDate.setHours(pointerDate.getHours() + 24) | |
} else if (recurringType === 'monthly') { | |
pointerTime = pointerDate.setMonth(pointerDate.getMonth() + 1) |
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
import * as AWS from 'aws-sdk' | |
import { DeleteItemOutput, DocumentClient, GetItemOutput, PutItemOutput, QueryOutput, | |
ScanOutput, UpdateItemOutput } from 'aws-sdk/clients/dynamodb' | |
AWS.config.update({ region: 'eu-central-1' }) | |
const { DynamoDB } = AWS | |
const dynamoDB: DocumentClient = new DynamoDB.DocumentClient() | |
export function query (attributeName: string, attributeValue: string): Promise<QueryOutput> { | |
const params = { |
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
import { S3 } from 'aws-sdk' | |
import { CreateBucketOutput, GetObjectOutput, HeadObjectOutput, ListObjectsV2Output, | |
PutObjectOutput } from 'aws-sdk/clients/s3' | |
const s3: S3 = new S3() | |
const BUCKET_NAME: string = process.env.BUCKET_NAME | |
export function appendToFile (params): Promise<PutObjectOutput> { | |
const { Body, ...rest } = params | |
return getFileContent(rest) |
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 fs = require('fs') | |
const path = require('path') | |
const JSZip = require('jszip') | |
const { promisify } = require('util') | |
const readFile = promisify(fs.readFile) | |
const readDir = promisify(fs.readdir) | |
const lstat = promisify(fs.lstat) | |
function addFilesToZip (jsZip, directoryPath, filesToInclude) { | |
const promiseArr = filesToInclude.map(async file => { |
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
interface Location { | |
lat: number, | |
long: number | |
} | |
// Converts from degrees to radians. | |
function toRadians (degrees: number): number { | |
return degrees * Math.PI / 180 | |
} |
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
export function lambdaResponse (body: any, statusCode = 200): any { | |
return { | |
body: JSON.stringify(body), | |
headers: { | |
'Access-Control-Allow-Credentials': true, | |
'Access-Control-Allow-Headers': '*', | |
'Access-Control-Allow-Origin': '*' | |
}, | |
statusCode, | |
isBase64Encoded: false |
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
"devDependencies": { | |
"babel-cli": "^6.26.0", | |
"babel-preset-env": "^1.7.0", | |
"nodemon": "^1.18.3" | |
}, | |
"babel": { | |
"presets": [ | |
"env" | |
] | |
}, |
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
#Convert private key to em format | |
openssl rsa -in domain.key -text > domain.pem | |
#Convert .crt file to .pem format | |
openssl x509 -in cert.crt -out cert.pem -outform PEM | |
openssl x509 -in ca.crt -out ca.pem -outform PEM |
OlderNewer