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

express-loadmill

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-loadmill - npm Package Compare versions

Comparing version 0.0.6 to 0.1.0-beta

45

index.d.ts

@@ -10,2 +10,5 @@ export = Loadmill;

/**
* Loadmill express middleware configuration options.
*/
type LoadmillOptions = {

@@ -15,3 +18,3 @@ /**

*/
verifyToken?: string;
verifyToken?: string

@@ -21,3 +24,41 @@ /**

*/
enableCors?: boolean;
enableCors?: boolean
/**
* Optional monitoring configuration.
* Sends data only during testing.
*/
monitor?: {
/**
* Personal access token for Loadmill monitoring API.
*/
apiToken: string
/**
* Enable monitoring during testing.
* Default: true.
*/
enabled?: boolean
/**
* The node process's associated (case insensitive) environment name (e.g. `Staging`, `Test`, `My_MacBook`, etc.).
* In general, Loadmill will monitor a single environment per load test.
*
* May contain (only) alphanumeric characters, `-` and `_`.
* Default: `default_env`.
*/
envName?: string;
/**
* The node process's associated (case insensitive) app / component / micro-service name
* (e.g. `web_app`, `billing_service`, `scheduler`, etc.).
*
* The app name is used to group together processes of the same "kind" and
* aggregate their performance metrics.
*
* May contain (only) alphanumeric characters, `-` and `_`.
* Default: `default_app`.
*/
appName?: string;
}
};
module.exports = function (options) {
var token = options && options.verifyToken;
var verifyToken = options && options.verifyToken;
var enableCookies = options && options.enableCookies;
var enableCors = !options || options.enableCors == null || options.enableCors;
if (options && options.monitor) {
activateMonitoring(options.monitor);
}
return function (req, res, next) {
checkCors({enableCors: enableCors, enableCookies: enableCookies}, req, res, function () {
return verifyDomain(token, req, res, next);
return verifyDomain(verifyToken, req, res, next);
});

@@ -14,2 +18,19 @@ };

function activateMonitoring(monitorOptions) {
if (monitorOptions.enabled == null || monitorOptions.enabled) {
var loadmillMonitor;
try {
loadmillMonitor = require('loadmill-monitor');
}
catch (err) {
console.error("Failed to require optional dependency 'loadmill-monitor' - " +
"did you remember to add it as a dependency to your package.json file?");
throw err;
}
loadmillMonitor(monitorOptions);
}
}
function checkCors(corsOptions, req, res, next) {

@@ -56,5 +77,5 @@ if (corsOptions.enableCors) {

function verifyDomain(token, req, res, next) {
if (token && req.url.indexOf("/loadmill-challenge/" + token + ".txt") === 0) {
res.send(token);
function verifyDomain(verifyToken, req, res, next) {
if (verifyToken && req.url.indexOf("/loadmill-challenge/" + verifyToken + ".txt") === 0) {
res.send(verifyToken);
}

@@ -61,0 +82,0 @@ else {

7

package.json
{
"name": "express-loadmill",
"version": "0.0.6",
"version": "0.1.0-beta",
"description": "Express middleware to enable crowdsourced load simulations via loadmill.com",

@@ -17,3 +17,6 @@ "keywords": [

"author": "itaysabato <itay@loadmill.com>",
"license": "MIT"
"license": "MIT",
"optionalDependencies": {
"loadmill-monitor": "^1.0.0"
}
}

Sorry, the diff of this file is not supported yet

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