Skip to content

Commit

Permalink
Updated project dependencies and security issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Heath101 committed Jan 11, 2021
1 parent b143e99 commit 05b0a8f
Show file tree
Hide file tree
Showing 34 changed files with 7,658 additions and 785 deletions.
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules/
.idea/
.DS_Store
*npm-debug.log
log/
coverage/
*config.json
.nyc_output
src
spec
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
extends: [ "leankit", "leankit/es6" ],
rules: {
strict: [ "error", "global" ],
"init-declarations": 0,
"global-require": 0,
"max-statements": [ "error", { "max": 35 } ]
},
parserOptions: {
ecmaVersion: 2017
}
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ tmp
.grapplehound.json
.nonstop.json
coverage/
.vscode/
.vscode/
.nyc_output/
108 changes: 0 additions & 108 deletions .jscsrc

This file was deleted.

105 changes: 0 additions & 105 deletions .jshintrc

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12.18
79 changes: 0 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ The object literal follows the format:
enableAccessLogs: true,// enables access logs
logging: {}, // configuration passed to autohost's whistlepunk instance
fount: undefined, // pass the app's fount instance to autohost
metrics: { // configuration for or instance of metronic
delimiter: '.',
prefix: undefined,
units: 'ms',
}

parseAhead: false, // parses path parameters before application middleware
handleRouteErrors: false, // wrap routes in try/catch
Expand Down Expand Up @@ -500,7 +495,6 @@ Envelopes are an abstraction around the incoming message or request. They are in
data: // the request/message body
headers: // request or message headers
logout: // a method to end the current session
metricKey: // a key containing the resource-action namespace
path: // url of the request (minus protocol/domain/port) OR message topic
session: // session hash
responseStream: // a write stream for streaming a response back to the client
Expand Down Expand Up @@ -665,79 +659,6 @@ A lot of visibility can be gained into what's happening in autohost in real-time
DEBUG=autohost* node index.js
```
## Metrics
Metrics are collected for routes, resource actions, authentication, authorization and errors. The metrics also include memory utlization as well as system memory and process load.
The [metronics](https://github.com/LeanKit-Labs/metronics) API is available via `host.metrics`. The `metrics` property will no be initialized until after the init call.
Metrics are not captured locally by default, but this can be opted into with the `useLocalAdapter` call.
```javascript
// turns on local metrics capture
host.metrics.useLocalAdapter();

// gets a report object
most.metrics.getReport();
```
### Metrics collected
Being aware of the metric keys used is important.
__System Level Metrics__
| Key | Name |
|-----|------|
| {prefix}.{hostName}.memory-total | SYSTEM_MEMORY_TOTAL |
| {prefix}.{hostName}.memory-allocated | SYSTEM_MEMORY_USED |
| {prefix}.{hostName}.memory-free | SYSTEM_MEMORY_FREE |
__Process Level Metrics__
| Key | Name |
|-----|------|
| {prefix}.{hostName}.{processTitle}.memory-physical | PROCESS_MEMORY_ALLOCATED |
| {prefix}.{hostName}.{processTitle}.memory-allocated | PROCESS_MEMORY_AVAILABLE |
| {prefix}.{hostName}.{processTitle}.memory-used | PROCESS_MEMORY_USED |
| {prefix}.{hostName}.{processTitle}.core-#-load | PROCESS_CORE_#_LOAD |
__Authentication & Authorization__
| Key | Name |
|-----|------|
| {prefix}.{hostName}.{processTitle}.authenticating | HTTP_AUTHENTICATION_DURATION |
| {prefix}.{hostName}.{processTitle}.authentication-attempted | HTTP_AUTHENTICATION_ATTEMPTS |
| {prefix}.{hostName}.{processTitle}.authentication-failed | HTTP_AUTHENTICATION_ERRORS |
| {prefix}.{hostName}.{processTitle}.authentication-granted | HTTP_AUTHENTICATION_GRANTED |
| {prefix}.{hostName}.{processTitle}.authentication-rejected | HTTP_AUTHENTICATION_REJECTED |
| {prefix}.{hostName}.{processTitle}.authentication-skipped | HTTP_AUTHENTICATION_SKIPPED |
| {prefix}.{hostName}.{processTitle}.authorizing | HTTP_AUTHORIZATION_DURATION |
| {prefix}.{hostName}.{processTitle}.authorization-attempted | HTTP_AUTHORIZATION_ATTEMPTS |
| {prefix}.{hostName}.{processTitle}.authorization-failed | HTTP_AUTHORIZATION_ERRORS |
| {prefix}.{hostName}.{processTitle}.authorization-granted | HTTP_AUTHORIZATION_GRANTED |
| {prefix}.{hostName}.{processTitle}.authorization-rejected | HTTP_AUTHORIZATION_REJECTED |
__Static Resources & Custom Routes__
| Key | Name |
|-----|------|
| {prefix}.{hostName}.{processTitle}.{url-verb}.ingress | HTTP_INGRESS |
| {prefix}.{hostName}.{processTitle}.{url-verb}.egress | HTTP_EGRESS |
| {prefix}.{hostName}.{processTitle}.{url-verb}.duration | HTTP_ROUTE_DURATION |
| {prefix}.{hostName}.{processTitle}.{url-verb}.exceptions | HTTP_ROUTE_EXCEPTIONS |
| {prefix}.{hostName}.{processTitle}.{url-verb}.errors | HTTP_ROUTE_ERRORS |
| {prefix}.{hostName}.{processTitle}.{url-verb}.requests | HTTP_REQUESTS |
__Resource Actions__
| Key | Name |
|-----|------|
| {prefix}.{hostName}.{processTitle}.{resource-action}.{transport}.ingress | HTTP_API_INGRESS |
| {prefix}.{hostName}.{processTitle}.{resource-action}.{transport}.egress | HTTP_API_EGRESS |
| {prefix}.{hostName}.{processTitle}.{resource-action}.{transport}.duration | HTTP_API_DURATION |
| {prefix}.{hostName}.{processTitle}.{resource-action}.{transport}.exceptions | HTTP_API_EXCEPTIONS |
| {prefix}.{hostName}.{processTitle}.{resource-action}.{transport}.errors | HTTP_API_ERRORS |
| {prefix}.{hostName}.{processTitle}.{resource-action}.{transport}.requests | HTTP_REQUESTS |
## Metadata
Metadata describing the routes and topic are available via an OPTIONS to api:
Expand Down
8 changes: 5 additions & 3 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var path = require( "path" );
var autohost = require( path.resolve( __dirname, "../src/index" ) );
var host = autohost( {
"use strict";

const path = require( "path" );
const autohost = require( path.resolve( __dirname, "../src/index" ) );
const host = autohost( {
resources: path.resolve( __dirname, "./resource" ),
static: path.resolve( __dirname, "./public" )
} );
Expand Down
6 changes: 4 additions & 2 deletions demo/resource/hello/resource.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"use strict";

module.exports = function() {
return {
name: "hello",
actions: {
default: {
url: "/",
method: "GET",
handle: function() {
handle() {
return "hello world";
}
}
}
};
};
};
Loading

0 comments on commit 05b0a8f

Please sign in to comment.