Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lambda-serverless-api

Package Overview
Dependencies
Maintainers
1
Versions
396
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-serverless-api - npm Package Compare versions

Comparing version 1.9.2 to 1.10.0

1

lib/api.js

@@ -92,2 +92,3 @@ const xor = require('lodash.xor');

wrap,
loadYaml: yaml.load,
generateSwagger: (existing = {}) => swagger(endpoints, existing),

@@ -94,0 +95,0 @@ generateDifference,

18

lib/util/yaml.js

@@ -7,3 +7,3 @@ const fs = require("fs");

const loadRecursive = (dir, data) => {
const loadRecursive = (dir, data, vars) => {
Object.keys(data).forEach((key) => {

@@ -13,16 +13,13 @@ let entry = get(data, key);

// replace yaml variables with defaults
entry = entry.replace(/\${[a-zA-Z0-9]+?:[a-zA-Z0-9]+?, ["']([a-zA-Z0-9]+?)["']}/g, "$1");
entry = entry.replace(/\${opt:([a-zA-Z0-9]+?)(?:, ["']([a-zA-Z0-9]+?)["'])?}/g, (_, k, v) => get(vars, k, v));
// load referenced yaml file
const match = /^\${file\(([^(){}$]+?)\)(?::([a-zA-Z0-9.]+?))?}$/g.exec(entry);
const match = /^\${file\((~?[a-zA-Z0-9._\-/]+?)\)(?::([a-zA-Z0-9.]+?))?}$/g.exec(entry);
if (match) {
const filePath = path.join(dir, match[1]);
const loaded = yaml.safeLoad(fs.readFileSync(filePath, 'utf8'));
entry = loadRecursive(
path.dirname(filePath),
get(loaded, match[2], loaded)
);
entry = loadRecursive(dir, get(loaded, match[2], loaded), vars);
}
}
if (entry instanceof Object) {
entry = loadRecursive(dir, entry);
entry = loadRecursive(dir, entry, vars);
}

@@ -34,5 +31,6 @@ set(data, key, entry);

module.exports.load = filePath => loadRecursive(
module.exports.load = (filePath, vars = {}) => loadRecursive(
path.dirname(filePath),
yaml.safeLoad(fs.readFileSync(filePath, 'utf8'))
yaml.safeLoad(fs.readFileSync(filePath, 'utf8')),
vars
);

@@ -19,7 +19,7 @@ {

"coveralls": "3.0.0",
"lambda-tdd": "1.11.11",
"lambda-tdd": "1.11.12",
"js-gardener": "1.11.20",
"semantic-release": "15.0.2"
},
"version": "1.9.2",
"version": "1.10.0",
"scripts": {

@@ -26,0 +26,0 @@ "test": "grunt gardener",

@@ -80,1 +80,5 @@ [![Build Status](https://img.shields.io/travis/simlu/lambda-serverless-api/master.svg)](https://travis-ci.org/simlu/lambda-serverless-api)

To monitor api errors and exceptions [lambda-rollbar](https://github.com/simlu/lambda-rollbar) can be enabled. Options are passed by putting them as `rollbar` into the constructor.
## Loading serverless.yml
Function `loadYaml` is exposed to load `serverless.yml` style files and resolve references and variables. This is handy to be used in `serverless.js` since the native loading currently has some issues.
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