oneday-core
Advanced tools
Comparing version 1.0.27 to 1.0.28
@@ -5,3 +5,2 @@ 'use strict'; | ||
aws.config.update({region: process.env.region}); | ||
const dynamoDb = new aws.DynamoDB.DocumentClient(); | ||
const sqs = new aws.SQS({apiVersion: '2012-11-05'}); | ||
@@ -34,2 +33,5 @@ const sns = new aws.SNS({region: process.env.region}); | ||
module.exports.isPresent = util.isPresent; | ||
module.exports.addDays = util.addDays; | ||
module.exports.isValidEmail = util.isValidEmail; | ||
module.exports.addIfPresent = util.addIfPresent; | ||
@@ -36,0 +38,0 @@ module.exports.ValidationError = error.ValidationError; |
{ | ||
"name": "oneday-core", | ||
"version": "1.0.27", | ||
"version": "1.0.28", | ||
"description": "Basic AWS util functions to ease development.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,8 +6,7 @@ /* | ||
var FuneralHome = { | ||
id: 'f979e361-8277-4ead-83f4-315b3f90bf16', | ||
name: 'FuneralHome', | ||
userCanInviteOthers: false, | ||
consumerCanInviteOthers: false, | ||
adminCanAddUsers: false, | ||
invitationValidityDays: 7 | ||
@@ -14,0 +13,0 @@ }; |
25
util.js
@@ -9,2 +9,5 @@ module.exports.getDynamoDbArn = getDynamoDbArn; | ||
module.exports.isPresent = isPresent; | ||
module.exports.addDays = addDays; | ||
module.exports.isValidEmail = isValidEmail; | ||
module.exports.addIfPresent = addIfPresent; | ||
@@ -68,10 +71,17 @@ function getDynamoDbArn(region, accountid, table) { | ||
function get(param){ | ||
function get(param) { | ||
return param === undefined ? null : param; | ||
} | ||
function isPresent(param){ | ||
function isPresent(param) { | ||
return param !== undefined; | ||
} | ||
function addIfPresent(resultObj, resultPropName, paramToBeChecked) { | ||
if (paramToBeChecked !== undefined && paramToBeChecked !== null) { | ||
resultObj[resultPropName] = paramToBeChecked; | ||
} | ||
return resultObj; | ||
} | ||
function isArray(a) { | ||
@@ -83,2 +93,13 @@ return (!!a) && (a.constructor === Array); | ||
return (!!a) && (a.constructor === Object); | ||
} | ||
function addDays(date, days) { | ||
const newDate = new Date(date); | ||
newDate.setDate(newDate.getDate() + days); | ||
return newDate; | ||
} | ||
function isValidEmail(email) { | ||
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | ||
return re.test(String(email).toLowerCase()); | ||
} |
19806
532