@@ -2,13 +2,34 @@ import type { IncomingMessage, ServerResponse } from "http";
2
2
import type { SlsAwsLambdaPlugin } from "../../defineConfig" ;
3
3
import type { QueueAttributes } from "./types" ;
4
4
import { getQueues } from "./utils" ;
5
- import { createRequestHandler } from "local-aws-sqs" ;
5
+ import { createRequestHandler , type ISqsServerOptions } from "local-aws-sqs" ;
6
6
7
- export const sqsPlugin = ( attributes ?: QueueAttributes ) : SlsAwsLambdaPlugin => {
7
+ export const sqsPlugin = (
8
+ attributes ?: QueueAttributes ,
9
+ serviceOptions ?: Pick < ISqsServerOptions , "emulateLazyQueues" | "emulateQueueCreationLifecycle" | "validateDlqDestination" >
10
+ ) : SlsAwsLambdaPlugin => {
8
11
let sqsRequestHandler = ( req : IncomingMessage , res : ServerResponse ) => { } ;
9
12
let region : string | undefined = undefined ;
10
13
let accountId : string | undefined = undefined ;
11
14
15
+ let validateDlqDestination = false ;
16
+ let emulateQueueCreationLifecycle = false ;
17
+ let emulateLazyQueues = false ;
18
+
19
+ if ( serviceOptions ) {
20
+ if ( typeof serviceOptions . validateDlqDestination == "boolean" ) {
21
+ validateDlqDestination = serviceOptions . validateDlqDestination ;
22
+ }
23
+
24
+ if ( typeof serviceOptions . emulateQueueCreationLifecycle == "boolean" ) {
25
+ emulateQueueCreationLifecycle = serviceOptions . emulateQueueCreationLifecycle ;
26
+ }
27
+
28
+ if ( typeof serviceOptions . emulateLazyQueues == "boolean" ) {
29
+ emulateLazyQueues = serviceOptions . emulateLazyQueues ;
30
+ }
31
+ }
32
+
12
33
const onReadyListener : Function [ ] = [ ] ;
13
34
14
35
const notifyReadyState = async ( ) => {
@@ -58,8 +79,9 @@ export const sqsPlugin = (attributes?: QueueAttributes): SlsAwsLambdaPlugin => {
58
79
port : port ,
59
80
region,
60
81
accountId,
61
- validateDlqDestination : false ,
62
- emulateQueueCreationLifecycle : false ,
82
+ validateDlqDestination,
83
+ emulateQueueCreationLifecycle,
84
+ emulateLazyQueues,
63
85
baseUrl : "/@sqs/" ,
64
86
queues : getQueues ( this . resources . sqs , this . lambdas , attributes ) ,
65
87
} ) ;
0 commit comments