@vyriy/smoke 0.2.1 → 0.3.2

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
@@ -42,13 +42,21 @@ if (result) {
42
42
  Default smoke request payload: `{ isSmoke: true }`.
43
43
 
44
44
  - `response`
45
- Default smoke response payload: `{ status: 'success' }`.
45
+ Default API Gateway-compatible smoke response:
46
+
47
+ ```ts
48
+ {
49
+ statusCode: 200,
50
+ body: JSON.stringify({
51
+ status: 'success',
52
+ }),
53
+ }
54
+ ```
46
55
 
47
56
  - `smoke(event)`
48
57
  Returns the smoke response when `event` matches the smoke request, otherwise returns `false`.
49
58
 
50
59
  ## Notes
51
60
 
52
- - matching is performed by comparing `JSON.stringify(event)` and `JSON.stringify(request)`
53
- - if property order differs, objects that are otherwise structurally equal may not match
61
+ - matching checks whether the incoming event is an object with `isSmoke: true`
54
62
  - the helper is best suited for small, stable smoke payloads
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vyriy/smoke",
3
- "version": "0.2.1",
3
+ "version": "0.3.2",
4
4
  "description": "Smoke request matcher for short-circuiting handlers in Vyriy projects",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/smoke.js CHANGED
@@ -1,7 +1,12 @@
1
1
  export const request = { isSmoke: true };
2
- export const response = { status: 'success' };
2
+ export const response = {
3
+ statusCode: 200,
4
+ body: JSON.stringify({
5
+ status: 'success',
6
+ }),
7
+ };
3
8
  export const smoke = (event) => {
4
- if (JSON.stringify(event) === JSON.stringify(request)) {
9
+ if (typeof event === 'object' && event && 'isSmoke' in event && event.isSmoke === request.isSmoke) {
5
10
  return response;
6
11
  }
7
12
  return false;
package/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { APIGatewayProxyResult } from 'aws-lambda';
1
2
  export type Request = Record<string, unknown>;
2
- export type Response = Record<string, unknown>;
3
+ export type Response = APIGatewayProxyResult;
3
4
  export type Smoke = (event: unknown) => Response | false;