@celastrina/http
Advanced tools
Comparing version 1.1.1-0.3beta to 1.1.1-0.4beta
{ | ||
"name": "@celastrina/http", | ||
"version": "1.1.10.3beta", | ||
"version": "1.1.10.4beta", | ||
"description": "HTTP Function Package for Celastrina", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,3 +16,3 @@ # celastrina | ||
## Quick-start | ||
To use Celastring.js simply deploy the following to your Microsoft Azure HTTP Trigger function: | ||
To use Celastrina.js simply deploy the following to your Microsoft Azure HTTP Trigger function: | ||
@@ -50,3 +50,3 @@ ``` | ||
Update you r Microsoft Azure function.json file with the following directive "entryPoint": "execute". Your in and out | ||
bdinges should be named "req" and "res" respectively. Your function.json should look something like this: | ||
bdinges should be named `req` and `res` respectively. Your `function.json` should look something like this: | ||
@@ -87,7 +87,7 @@ ``` | ||
1. **NumericProperty**: `key=value` pair representing a Numberic data-type. | ||
2. **BooleanProperty**: `key=value` pair representing a true/false data type. The `BooleanProperty` simple looks for | ||
1. `NumericProperty`: `key=value` pair representing a Numberic data-type. | ||
2. `BooleanProperty`: `key=value` pair representing a true/false data type. The `BooleanProperty` simple looks for | ||
`string === "true"` for `true`, `false` otherwise. | ||
3. **StringProperty**: `key=value` pair for string, duh. | ||
4. **JsonProperty**: A serialized JavaScript object parsed using `JSON.parse()`. | ||
3. `StringProperty`: `key=value` pair for string, duh. | ||
4. `JsonProperty`: A serialized JavaScript object parsed using `JSON.parse()`. | ||
@@ -97,3 +97,3 @@ This HTTP package also includes specialized property types will discuss later in this document. Celastrina.js takes | ||
`Property` instance. All `Property` instances are converted to thier respective types during the bootstrp life-cycle of | ||
the Celastring.js function. More on life-cycle later. | ||
the Celastrina.js function. More on life-cycle later. | ||
@@ -106,10 +106,10 @@ A `Property` instance has the following constructor: | ||
- **name** {_string_}: The name, or KEY, of the property in the process.env. This paramter is required and cannot be | ||
- `name` {`string`}: The name, or KEY, of the property in the process.env. This paramter is required and cannot be | ||
undefined. | ||
- **secure** {_boolean_}: Determines if this property actually contains a link to a Microsoft Azure Key Vault Secret | ||
- `secure` {`boolean`}: Determines if this property actually contains a link to a Microsoft Azure Key Vault Secret | ||
Identifier. This parameter is optional and the default is `false`. | ||
- **defaultValue** {_\*_}: The default value to use if the entry in process.env is `null` or `unddefined. The super | ||
- `defaultValue` {`*`}: The default value to use if the entry in process.env is `null` or `unddefined. The super | ||
class `Property` will accept Any (`*`) value but implentations such as `StringProperty` or `BooleanProperty` will enforce thier | ||
respective types. This parameter is optional and will default to `null`. | ||
- **factory** {_\*_}: RESERVED. Current not used and optional. Defaults to `null`. | ||
- `factory` {`*`}: RESERVED. Currently, not used. | ||
@@ -133,5 +133,5 @@ #### Using a Property | ||
- **name** {_string_}: The firendly name of this function. This name is used for diagnostics, insights, and logging and | ||
- `name` {`string`}: The firendly name of this function. This name is used for diagnostics, insights, and logging and | ||
should not be seen by the caller. | ||
- **managed** {_boolean_}: Determines if this function runs in a secure `managed` mode. More on that later. | ||
- `managed` {`boolean`}: Determines if this function runs in a secure `managed` mode. More on that later. | ||
@@ -162,5 +162,5 @@ As stated you may use the primitive types or corrosponding `Property` instances. | ||
- **addApplicationAuthorization** {_ApplicationAuthorization_} | ||
- **addResourceAuthorization** {_string_} | ||
- **addFunctionRole** {_FunctionRole_} | ||
- `addApplicationAuthorization` {`ApplicationAuthorization`} | ||
- `addResourceAuthorization` {`string`} | ||
- `addFunctionRole` {`FunctionRole`} | ||
@@ -170,3 +170,3 @@ More on what these mean later... The `Configuration` is only available during the bootstrap life-cycle. After that, any | ||
#### The Celastring.js Life-Cycle | ||
#### The Celastrina.js Life-Cycle | ||
Celastrina.js follows a fairly straight forward life-cycle of promises to execute work. The basic life-cycle executed | ||
@@ -202,4 +202,53 @@ when the 'execute' method is invoked in BaseFunction is, in order, as follows: | ||
In the processing phase, the HTTP package looks at the HTTP method in the request and invokes the `_[method]` function | ||
in the class. For example, if the HTTP method is GET, then `_get(context)` is invoked. | ||
in the class. For example, if the HTTP method is GET, then `_get(context)` is invoked. A typical HTTP Trigger function | ||
might look like: | ||
``` | ||
class MyNewHTTPTriggerFunction extends JwtJSONHTTPFunction { | ||
async initialize(context) { | ||
return new Promise((resolve, reject) => { | ||
// Do some initialization stuff | ||
resolve(); | ||
}); | ||
} | ||
async load(context) { | ||
return new Promise((resolve, reject) => { | ||
// Load some objects from your data store | ||
resolve(); | ||
}); | ||
} | ||
async _get(context) { | ||
return new Promise((resolve, reject) => { | ||
context.send({message: "_get invoked."}); | ||
resolve(); | ||
}); | ||
} | ||
async _post(context) { | ||
return new Promise((resolve, reject) => { | ||
context.send({message: "_post invoked."}); | ||
resolve(); | ||
}); | ||
} | ||
async save(context) { | ||
return new Promise((resolve, reject) => { | ||
// Save some objects to your data store | ||
resolve(); | ||
}); | ||
} | ||
async terminate(context) { | ||
return new Promise((resolve, reject) => { | ||
// Do your cleanup. | ||
resolve(); | ||
}); | ||
} | ||
} | ||
module.exports = new MyNewHTTPTriggerFunction(config); | ||
``` | ||
### So, what about managed mode? | ||
@@ -242,3 +291,3 @@ Glad you asked! Managed mode puts Celastrina.js inso a secure managed resource mode. This allows Celastrina.js to not only | ||
#### So, why should I use Azure Key Vault and not Deployment Slots? | ||
#### So, why should I use Azure Key Vault and not Application Settings? | ||
Well, that's a great questions. I happen to trust more the added layer os security from Azure Key Vault and the clearer | ||
@@ -261,3 +310,3 @@ Seperation of Duties (SOD) in managing securey properties in Key Vault. It allows a configuration manager or other higher | ||
"function.managed": "true" | ||
"YOUR_VUALT_SECURE_PROPERTY": "https://\[Your Key Vault\].vault.azure.net/secrets/\[Your Secret\]/\[Your Version ID\]" | ||
"YOUR_VUALT_SECURE_PROPERTY": "https://[Your Key Vault].vault.azure.net/secrets/[Your Secret]/[Your Version ID]" | ||
} | ||
@@ -314,3 +363,3 @@ } | ||
Awesome! So you finally realized that roll'n your own user management system is a bad idea and have set up Azure AD B2C! | ||
I'm proud of you, that's a big step! If I was wrong and you havent, I choose not to help you. Just don't. If you're gonna | ||
I'm proud of you, that's a big step! If I was wrong and you haven't, I choose not to help you. Just don't. If you're gonna | ||
use Azure, use Azure AD. If you are an enterprise and writing an application for employees, you're almost there. If not, | ||
@@ -317,0 +366,0 @@ use Azure AD b2C for your customers. Its basically free for most small to medium application so there is really no reason |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
75481
360