jaypie 1.0.22 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,15 +52,16 @@ npm install jaypie
52
52
 
53
53
  `@jaypie/core` is included in `jaypie`. Almost every Jaypie package requires core.
54
54
 
55
- #### Peer Dependencies
55
+ #### Peer Packages
56
56
 
57
- You must install peer dependencies for your project.
57
+ These packages are included in `jaypie`. They may be installed separately in the future.
58
58
 
59
59
  | Package | Exports | Description |
60
60
  | ------- | ------- | ----------- |
61
- | `@jaypie/aws` | `getSecret` | AWS helpers |
61
+ | `@jaypie/aws` | `getMessages`, `getSecret`, `sendBatchMessages`, `sendMessage` | AWS helpers |
62
+ | `@jaypie/datadog | `submitMetric`, `submitMetricSet` | Datadog helpers |
62
63
  | `@jaypie/lambda` | `lambdaHandler` | Lambda entry point |
63
- | `@jaypie/mongoose` | `connectFromSecretEnv`, `disconnect`, `mongoose` | MongoDB management |
64
+ | `@jaypie/mongoose` | `connect`, `connectFromSecretEnv`, `disconnect`, `mongoose` | MongoDB management |
64
65
 
65
66
  #### TestKit
66
67
 
@@ -176,6 +177,7 @@ const response = await sendMessage({ body, queueUrl });
176
177
  ```javascript
177
178
  import {
178
179
  CDK,
180
+ DATADOG,
179
181
  ERROR,
180
182
  HTTP,
181
183
  VALIDATE,
@@ -192,6 +194,13 @@ import {
192
194
 
193
195
  See [constants.js in @jaypie/core](https://github.com/finlaysonstudio/jaypie-core/blob/main/src/core/constants.js).
194
196
 
197
+ #### `DATADOG`
198
+
199
+ * `DATADOG.METRIC.TYPE.UNKNOWN`
200
+ * `DATADOG.METRIC.TYPE.COUNT`
201
+ * `DATADOG.METRIC.TYPE.RATE`
202
+ * `DATADOG.METRIC.TYPE.GAUGE`
203
+
195
204
  #### `ERROR`
196
205
 
197
206
  Default messages and titles for Jaypie errors.
@@ -229,6 +238,62 @@ See `HTTP` for status codes.
229
238
  * `JAYPIE` - for consistency across Jaypie
230
239
  * `PROJECT` - for consistency across projects
231
240
 
241
+ ### Datadog
242
+
243
+ ```javascript
244
+ const {
245
+ submitMetric,
246
+ submitMetricSet
247
+ } = require("jaypie");
248
+ ```
249
+
250
+ #### `submitMetric({ name, tags, type, value })`
251
+
252
+ ```javascript
253
+ import { submitMetric } from "jaypie";
254
+
255
+ await submitMetric({
256
+ name: "jaypie.metric",
257
+ type: DATADOG.METRIC.TYPE.COUNT,
258
+ value: 1,
259
+ });
260
+ ```
261
+
262
+ | Parameter | Type | Required | Description |
263
+ | --------- | ---- | -------- | ----------- |
264
+ | apiKey | `string` | No | Datadog API key; checks `process.env.DATADOG_API_KEY` |
265
+ | apiSecret | `string` | No | AWS Secret name holding Datadog API key; checks `process.env.SECRET_DATADOG_API_KEY`. Preferred method of retrieving key |
266
+ | name | `string` | Yes | Name of the metric |
267
+ | type | `string` | No | Defaults to `DATADOG.METRIC.TYPE.UNKNOWN` |
268
+ | value | `number` | Yes | Value of the metric |
269
+ | tags | `array`, `object` | No | Tags for the metric. Accepts arrays `["key:value"]` or objects `{"key":"value"}` |
270
+ | timestamp | `number` | No | Unix timestamp; defaults to `Date.now()` |
271
+
272
+ #### `submitMetricSet({ tags, type, valueSet })`
273
+
274
+ ```javascript
275
+ import { submitMetricSet } from "jaypie";
276
+
277
+ await submitMetricSet({
278
+ type: DATADOG.METRIC.TYPE.GAUGE,
279
+ valueSet: {
280
+ "jaypie.metric.a": 1,
281
+ "jaypie.metric.b": 2,
282
+ "jaypie.metric.c": 3,
283
+ },
284
+ });
285
+ ```
286
+
287
+
288
+ | Parameter | Type | Required | Description |
289
+ | --------- | ---- | -------- | ----------- |
290
+ | apiKey | `string` | No | Datadog API key; checks `process.env.DATADOG_API_KEY` |
291
+ | apiSecret | `string` | No | AWS Secret name holding Datadog API key; checks `process.env.SECRET_DATADOG_API_KEY`. Preferred method of retrieving key |
292
+ | type | `string` | No | Defaults to `DATADOG.METRIC.TYPE.UNKNOWN` |
293
+ | valueSet | `object` | Yes | Key-value pairs where the key is the metric name and the value is the metric value (number) |
294
+ | tags | `array`, `object` | No | Tags for the metric. Accepts arrays `["key:value"]` or objects `{"key":"value"}` |
295
+ | timestamp | `number` | No | Unix timestamp; defaults to `Date.now()` |
296
+
232
297
  ### Errors
233
298
 
234
299
  #### Throwing/Catching Errors
@@ -590,12 +655,30 @@ const log = defaultLogger.with({ customProperty: "customValue" });
590
655
 
591
656
  ```javascript
592
657
  import {
658
+ connect,
593
659
  connectFromSecretEnv,
594
660
  disconnect,
595
661
  mongoose,
596
662
  } from "jaypie";
597
663
  ```
598
664
 
665
+ #### `connect`
666
+
667
+ Jaypie lifecycle method to connect to MongoDB. Uses `process.env.SECRET_MONGODB_URI` AWS Secret or `process.env.MONGODB_URI` string to connect.
668
+
669
+ ```javascript
670
+ import { connect, disconnect, lambdaHandler, mongoose } from "jaypie";
671
+
672
+ const handler = lambdaHandler(async({event}) => {
673
+ // mongoose is already connected
674
+ return "Hello World";
675
+ }, {
676
+ name: "lambdaReference"
677
+ setup: [connect],
678
+ teardown: [disconnect],
679
+ });
680
+ ```
681
+
599
682
  #### `connectFromSecretEnv`
600
683
 
601
684
  Jaypie lifecycle method to connect to MongoDB using `process.env.MONGO_CONNECTION_STRING`.
@@ -2,6 +2,7 @@
2
2
 
3
3
  var core = require('@jaypie/core');
4
4
  var aws = require('@jaypie/aws');
5
+ var datadog = require('@jaypie/datadog');
5
6
  var lambda = require('@jaypie/lambda');
6
7
  var mongoose = require('@jaypie/mongoose');
7
8
 
@@ -19,6 +20,12 @@ Object.keys(aws).forEach(function (k) {
19
20
  get: function () { return aws[k]; }
20
21
  });
21
22
  });
23
+ Object.keys(datadog).forEach(function (k) {
24
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
25
+ enumerable: true,
26
+ get: function () { return datadog[k]; }
27
+ });
28
+ });
22
29
  Object.keys(lambda).forEach(function (k) {
23
30
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
24
31
  enumerable: true,
@@ -1,4 +1,5 @@
1
1
  export * from '@jaypie/core';
2
2
  export * from '@jaypie/aws';
3
+ export * from '@jaypie/datadog';
3
4
  export * from '@jaypie/lambda';
4
5
  export * from '@jaypie/mongoose';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaypie",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "author": "Finlayson Studio",
5
5
  "type": "module",
6
6
  "exports": {
@@ -28,9 +28,10 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@jaypie/aws": "^1.0.5",
31
- "@jaypie/core": "^1.0.26",
31
+ "@jaypie/core": "^1.0.28",
32
+ "@jaypie/datadog": "^1.0.0",
32
33
  "@jaypie/lambda": "^1.0.4",
33
- "@jaypie/mongoose": "^1.0.6"
34
+ "@jaypie/mongoose": "^1.0.7"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@jaypie/testkit": "^1.0.18",
package/src/index.js CHANGED
@@ -7,5 +7,6 @@
7
7
  export * from "@jaypie/core";
8
8
 
9
9
  export * from "@jaypie/aws";
10
+ export * from "@jaypie/datadog";
10
11
  export * from "@jaypie/lambda";
11
12
  export * from "@jaypie/mongoose";