serverless-async-storage
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -17,4 +17,8 @@ "use strict"; | ||
.forEach((functionName) => { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
const functionObject = this.serverless.service.getFunction(functionName); | ||
const isPluginEnabled = ((_b = (_a = this.serverless.service.custom) === null || _a === void 0 ? void 0 : _a["serverless-async-storage"]) === null || _b === void 0 ? void 0 : _b.enabled) === true; | ||
if (!isPluginEnabled) { | ||
return; | ||
} | ||
const originalHandler = functionObject.handler; | ||
@@ -25,3 +29,2 @@ const serverlessPath = this.serverless.config.servicePath; | ||
functionObject.environment.SAS_HANDLER = `${offline ? serverlessPath : "/var/task"}/${originalHandler}`; | ||
functionObject.environment.SAS_ENABLED = `${(_c = (_b = (_a = this.serverless.service.custom) === null || _a === void 0 ? void 0 : _a["serverless-async-storage"]) === null || _b === void 0 ? void 0 : _b.enabled) !== null && _c !== void 0 ? _c : false}`; | ||
}); | ||
@@ -28,0 +31,0 @@ } |
@@ -7,9 +7,6 @@ "use strict"; | ||
function asyncStoreWrapper(...args) { | ||
const pluginEnabled = process.env.SAS_ENABLED === "true"; | ||
const splits = process.env.SAS_HANDLER.split("."); | ||
const handlerName = splits.pop(); | ||
const filePath = splits.join("."); | ||
return store_1.asyncLocalStorage.run(store_factory_1.StoreFactory.getStore(pluginEnabled | ||
? store_factory_1.StoreTypeEnum.TransientStore | ||
: store_factory_1.StoreTypeEnum.PerpetualStore), () => { | ||
return store_1.asyncLocalStorage.run(store_factory_1.StoreFactory.getStore(store_factory_1.StoreTypeEnum.TransientStore), () => { | ||
const fileModule = require(`${filePath}`); | ||
@@ -16,0 +13,0 @@ const handler = fileModule[handlerName]; |
import { StoreI } from "./store-interface"; | ||
export declare enum StoreTypeEnum { | ||
TransientStore = "TransientStore", | ||
PerpetualStore = "PerpetualStore" | ||
TransientStore = "TransientStore" | ||
} | ||
@@ -6,0 +5,0 @@ export declare class StoreFactory { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StoreFactory = exports.StoreTypeEnum = void 0; | ||
const perpetual_store_1 = require("./perpetual-store"); | ||
const transient_store_1 = require("./transient-store"); | ||
@@ -9,3 +8,2 @@ var StoreTypeEnum; | ||
StoreTypeEnum["TransientStore"] = "TransientStore"; | ||
StoreTypeEnum["PerpetualStore"] = "PerpetualStore"; | ||
})(StoreTypeEnum || (exports.StoreTypeEnum = StoreTypeEnum = {})); | ||
@@ -17,4 +15,2 @@ class StoreFactory { | ||
return new transient_store_1.TransientStore(); | ||
case StoreTypeEnum.PerpetualStore: | ||
return new perpetual_store_1.PerpetualStore(); | ||
default: | ||
@@ -21,0 +17,0 @@ throw new Error('Invalid store type'); |
@@ -7,12 +7,15 @@ "use strict"; | ||
function getFromStore(key) { | ||
return exports.asyncLocalStorage.getStore().getFromStore(key); | ||
var _a; | ||
return (_a = exports.asyncLocalStorage.getStore()) === null || _a === void 0 ? void 0 : _a.getFromStore(key); | ||
} | ||
exports.getFromStore = getFromStore; | ||
function setInStore(key, value) { | ||
return exports.asyncLocalStorage.getStore().setInStore(key, value); | ||
var _a; | ||
return (_a = exports.asyncLocalStorage.getStore()) === null || _a === void 0 ? void 0 : _a.setInStore(key, value); | ||
} | ||
exports.setInStore = setInStore; | ||
function clearStore() { | ||
return exports.asyncLocalStorage.getStore().clearStore(); | ||
var _a; | ||
return (_a = exports.asyncLocalStorage.getStore()) === null || _a === void 0 ? void 0 : _a.clearStore(); | ||
} | ||
exports.clearStore = clearStore; |
{ | ||
"name": "serverless-async-storage", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Ensure separate contexts for consecutive warm lambda executions", | ||
@@ -17,3 +17,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"build": "tsc --project tsconfig.build.json", | ||
"cleanup": "rm -rf dist", | ||
@@ -44,5 +44,8 @@ "prerelease": "npm run cleanup && npm run build", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.12.7", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.2.2", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
2
13746
5
18
159