@digitraffic/common 2024.12.10-1 → 2024.12.10-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.
@@ -8,6 +8,10 @@ import type { DigitrafficStack } from "./stack/stack.js";
8
8
  */
9
9
  export declare class DigitrafficSqsQueue extends Queue {
10
10
  static create(stack: DigitrafficStack, name: string, props: QueueProps): DigitrafficSqsQueue;
11
+ /**
12
+ * Create a fifo with given name. No DLQ created!
13
+ */
14
+ static createFifo(stack: DigitrafficStack, name: string, props: QueueProps): DigitrafficSqsQueue;
11
15
  }
12
16
  export declare class DigitrafficDLQueue {
13
17
  static create(stack: DigitrafficStack, name: string): DigitrafficSqsQueue;
@@ -34,18 +34,28 @@ export class DigitrafficSqsQueue extends Queue {
34
34
  const queueName = `${stack.configuration.shortName}-${name}-Queue`;
35
35
  const queueProps = {
36
36
  ...props,
37
- ...{
38
- encryption: QueueEncryption.KMS_MANAGED,
39
- queueName,
40
- deadLetterQueue: props.deadLetterQueue ?? {
41
- maxReceiveCount: 2,
42
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
43
- queue: DigitrafficDLQueue.create(stack, name),
44
- },
37
+ encryption: QueueEncryption.KMS_MANAGED,
38
+ queueName,
39
+ deadLetterQueue: props.deadLetterQueue ?? {
40
+ maxReceiveCount: 2,
41
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
42
+ queue: DigitrafficDLQueue.create(stack, name),
45
43
  },
46
44
  };
47
45
  return new DigitrafficSqsQueue(stack, queueName, queueProps);
48
46
  }
47
+ /**
48
+ * Create a fifo with given name. No DLQ created!
49
+ */
50
+ static createFifo(stack, name, props) {
51
+ const queueName = `${stack.configuration.shortName}-${name}-Queue.fifo`;
52
+ const queueProps = {
53
+ ...props,
54
+ encryption: QueueEncryption.KMS_MANAGED,
55
+ queueName
56
+ };
57
+ return new DigitrafficSqsQueue(stack, queueName, queueProps);
58
+ }
49
59
  }
50
60
  export class DigitrafficDLQueue {
51
61
  static create(stack, name) {
@@ -21,19 +21,23 @@ export declare class LambdaResponse {
21
21
  /**
22
22
  * Create LambdaResponse for HTTP 400
23
23
  */
24
- static badRequest(body: string): LambdaResponse;
24
+ static badRequest(error: string): LambdaResponse;
25
25
  /**
26
26
  * Create LambdaResponse for HTTP 404
27
27
  */
28
- static notFound(): LambdaResponse;
28
+ static notFound(error?: string): LambdaResponse;
29
29
  /**
30
30
  * Create LambdaResponse for HTTP 500
31
31
  */
32
- static internalError(): LambdaResponse;
32
+ static internalError(error?: string): LambdaResponse;
33
+ /**
34
+ * Create LambdaResponse for HTTP 401
35
+ */
36
+ static unauthorized(error?: string): LambdaResponse;
33
37
  /**
34
38
  * Create LambdaResponse for HTTP 501
35
39
  */
36
- static notImplemented(): LambdaResponse;
40
+ static notImplemented(error?: string): LambdaResponse;
37
41
  private static createForString;
38
42
  private static createForBase64;
39
43
  }
@@ -36,26 +36,32 @@ export class LambdaResponse {
36
36
  /**
37
37
  * Create LambdaResponse for HTTP 400
38
38
  */
39
- static badRequest(body) {
40
- return this.createForString(400, body);
39
+ static badRequest(error) {
40
+ return this.createForString(400, error);
41
41
  }
42
42
  /**
43
43
  * Create LambdaResponse for HTTP 404
44
44
  */
45
- static notFound() {
46
- return this.createForString(404, "Not found");
45
+ static notFound(error = "Not found") {
46
+ return this.createForString(404, error);
47
47
  }
48
48
  /**
49
49
  * Create LambdaResponse for HTTP 500
50
50
  */
51
- static internalError() {
52
- return this.createForString(500, "Internal error");
51
+ static internalError(error = "Internal error") {
52
+ return this.createForString(500, error);
53
+ }
54
+ /**
55
+ * Create LambdaResponse for HTTP 401
56
+ */
57
+ static unauthorized(error = "Unauthorized") {
58
+ return this.createForString(401, error);
53
59
  }
54
60
  /**
55
61
  * Create LambdaResponse for HTTP 501
56
62
  */
57
- static notImplemented() {
58
- return this.createForString(501, "Not implemented");
63
+ static notImplemented(error = "Not implemented") {
64
+ return this.createForString(501, error);
59
65
  }
60
66
  static createForString(status, body, fileName) {
61
67
  return this.createForBase64(status, toBase64(body), fileName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2024.12.10-1",
3
+ "version": "2024.12.10-2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "repository": {