New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

oneday-core

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oneday-core - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

66

db.js

@@ -6,12 +6,26 @@ const aws = require('aws-sdk');

module.exports.getFromDb = getFromDb;
module.exports.getFromDbElseThrow = getFromDbElseThrow;
module.exports.queryDb = queryDb;
module.exports.queryDbElseThrow = queryDbElseThrow;
async function getFromDbElseThrow(params, filter) {
return await getItem(params, filter, true);
}
async function getFromDb(params, filter) {
return await getItem(params, filter, false);
}
async function getItem(params, filter, isThrow) {
const result = await dynamoDb.get(params).promise();
if (typeof result.Item === 'undefined') {
throw new {
code: "NOT_FOUND",
message: "No data found for given params: " + params
};
if (isThrow) {
throw new {
code: "NOT_FOUND",
message: "No data found for given params: " + params
};
} else {
return null;
}
}

@@ -22,6 +36,10 @@

if (filtered.size === 0) {
throw new {
code: "NOT_FOUND",
message: "No data found for given params: " + params
};
if (isThrow) {
throw new {
code: "NOT_FOUND",
message: "No data found for given params: " + params
};
} else {
return null;
}
}

@@ -33,10 +51,22 @@ return filtered;

async function queryDbElseThrow(params, filter) {
return await query(params, filter, true);
}
async function queryDb(params, filter) {
return await query(params, filter, false);
}
async function query(params, filter, isThrow) {
const result = await dynamoDb.query(params).promise();
if (result.Count === 0) {
throw new {
code: "NOT_FOUND",
message: "No data found for given params: " + params
};
if (isThrow) {
throw new {
code: "NOT_FOUND",
message: "No data found for given params: " + params
};
} else {
return [];
}
}

@@ -47,6 +77,10 @@

if (filtered.size === 0) {
throw new {
code: "NOT_FOUND",
message: "No data found for given params: " + params
};
if (isThrow) {
throw new {
code: "NOT_FOUND",
message: "No data found for given params: " + params
};
} else {
return [];
}
}

@@ -53,0 +87,0 @@ return filtered;

@@ -19,4 +19,7 @@ 'use strict';

module.exports.getFromDb = db.getFromDb;
module.exports.getFromDbElseThrow = db.getFromDbElseThrow;
module.exports.queryDb = db.queryDb;
module.exports.queryDbElseThrow = db.queryDbElseThrow;
module.exports.hasProperties = util.hasProperties;

@@ -23,0 +26,0 @@ module.exports.isArray = util.isArray;

{
"name": "oneday-core",
"version": "1.0.9",
"version": "1.0.10",
"description": "Basic AWS util functions to ease development.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc