azure-chaos-fn
Advanced tools
Comparing version
module.exports = { | ||
v1: require('./v1') | ||
parsers: require('./parsers'), | ||
validators: require('./validators') | ||
} |
{ | ||
"name": "azure-chaos-fn", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "The base module for all azure-chaos extensions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,88 +5,68 @@ # azure-chaos-fn | ||
> To scaffold projects more easily, see [generator-azure-chaos-fn](https://github.com/bengreenier/generator-azure-chaos-fn). :sparkles: | ||
A helper module for all `node` [azure-chaos](https://github.com/bengreenier/azure-chaos) extensions :gear: :robot: | ||
The base module for all [azure-chaos](https://github.com/bengreenier/azure-chaos) extensions :gear: :robot_face: | ||
 | ||
This module defines a `javascript` framework that is helpful when authoring [azure-chaos](https://github.com/bengreenier/azure-chaos) functions. It provides a lightweight processing pipeline that allows extension authors to more easily engineer chaos, without worrying about communication details with the orchestrator. | ||
This module defines a `javascript` framework that is helpful when authoring [azure-chaos](https://github.com/bengreenier/azure-chaos) functions. It provides lightweight helpers that allow extension authors to more easily engineer chaos, without worrying about communication details with the orchestrator. | ||
## API | ||
> __If your functions are `async` they should return a `Promise`!__ | ||
This is the exported API from the `azure-chaos-fn` module. | ||
Current version is `v1` - access it with `require('azure-chaos-fn/v1')` or `require('azure-chaos-fn').v1`. | ||
### validators | ||
## start.bootStrap | ||
Request validation helpers. Useful to ensure data coming in is behaving as expecting. | ||
`Function` that bootstraps the request to start chaos. Should be given `context` (from azure functions) and `func` (the function to run). | ||
Example: | ||
``` | ||
const yourFunc = require('./your-func') | ||
bootStrap(context, yourFunc) | ||
const validate = require('azure-chaos-fn/validators') | ||
``` | ||
## stop.bootStrap | ||
#### accessToken | ||
`Function` that bootstraps the request to stop chaos. Should be given `context` (from azure functions) and `func` (the function to run). | ||
Validates that the `body` of a `req` object contains a valid `accessToken`. | ||
Example: | ||
``` | ||
const yourFunc = require('./your-func') | ||
bootStrap(context, yourFunc) | ||
try { require('azure-chaos-fn/validators').accessToken(req) } catch (ex) { console.error(`error: ${ex}`) } | ||
``` | ||
### ChaosRequest | ||
#### resources | ||
Represents a request | ||
Validates that the `body` of a `req` object contains a valid `resources` array. | ||
#### accessToken | ||
``` | ||
try { require('azure-chaos-fn/validators').resources(req) } catch (ex) { console.error(`error: ${ex}`) } | ||
``` | ||
`String` - the access token to use when issuing requests to azure | ||
### parsers | ||
#### resourceIds | ||
> Note: these depend on the [validators](#validators) to ensure only valid data is parsed. | ||
`Array` of [ChaosResourceId](#chaosresourceid)s | ||
Request parser helpers. Useful to parse valid request data into models. | ||
### ChaosResponse | ||
``` | ||
const parsers = require('azure-chaos-fn/parsers') | ||
``` | ||
#### status | ||
#### accessTokenToCredentials | ||
`Function` that takes a `status` (a Number) and optionally a `desc` (a String) that describe the result of the request for chaos. | ||
Inflates the `accessToken` from a `req` objects `body` into a [ms-rest-azure](https://www.npmjs.com/package/ms-rest-azure) compatible credentials object. | ||
Example: | ||
``` | ||
res.status(200, JSON.stringify({status: 'all good'})) | ||
const credentials = require('azure-chaos-fn/parsers').accessTokenToCredentials(req) | ||
``` | ||
#### end | ||
#### resourcesToObjects | ||
`Function` that locks the response, indicating it's ready to be sent and will have no more action taken upon it. This can only be called once. | ||
Inflates the `resources` from a `req` objects `body` into a collection of objects containing the following properties: | ||
#### wasEnded | ||
+ `subscriptionId` - the azure subscription id to target | ||
+ `resourceGroupName` - the azure resource group name to target | ||
+ `resourceName` - the azure resource name to target | ||
`Bool` that indicates if [end](#end) was called. | ||
``` | ||
const objs = require('azure-chaos-fn/parsers').resourcesToObjects(req) | ||
``` | ||
### ChaosResourceId | ||
Represents the tri-part `resourceIds` that are passed in a `ChaosRequest`. | ||
#### subscription | ||
`String` - the subscription id | ||
#### resourceId | ||
`String` - the resource id | ||
#### resourceGroup | ||
`String` - The resource group | ||
## License | ||
MIT |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
5517
-52.37%44
-81.74%71
-21.98%1
Infinity%