@gugananuvem/aws-local-simulator 1.0.9 → 1.0.11

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.
Files changed (41) hide show
  1. package/README.md +204 -192
  2. package/bin/aws-local-simulator.js +62 -62
  3. package/package.json +2 -2
  4. package/src/config/config-loader.js +112 -112
  5. package/src/config/default-config.js +65 -65
  6. package/src/config/env-loader.js +68 -66
  7. package/src/index.js +130 -130
  8. package/src/index.mjs +123 -123
  9. package/src/server.js +221 -219
  10. package/src/services/apigateway/index.js +66 -66
  11. package/src/services/apigateway/server.js +434 -434
  12. package/src/services/apigateway/simulator.js +1251 -1251
  13. package/src/services/cognito/index.js +65 -65
  14. package/src/services/cognito/server.js +228 -228
  15. package/src/services/cognito/simulator.js +847 -847
  16. package/src/services/dynamodb/index.js +70 -70
  17. package/src/services/dynamodb/server.js +121 -121
  18. package/src/services/dynamodb/simulator.js +620 -614
  19. package/src/services/ecs/index.js +66 -0
  20. package/src/services/ecs/server.js +234 -0
  21. package/src/services/ecs/simulator.js +845 -0
  22. package/src/services/eventbridge/index.js +84 -84
  23. package/src/services/index.js +18 -18
  24. package/src/services/lambda/handler-loader.js +172 -172
  25. package/src/services/lambda/index.js +72 -72
  26. package/src/services/lambda/route-registry.js +274 -274
  27. package/src/services/lambda/server.js +152 -152
  28. package/src/services/lambda/simulator.js +284 -277
  29. package/src/services/s3/index.js +69 -69
  30. package/src/services/s3/server.js +238 -238
  31. package/src/services/s3/simulator.js +740 -740
  32. package/src/services/sns/index.js +75 -75
  33. package/src/services/sqs/index.js +95 -95
  34. package/src/services/sqs/server.js +273 -273
  35. package/src/services/sqs/simulator.js +659 -659
  36. package/src/template/aws-config-template.js +87 -87
  37. package/src/template/aws-config-template.mjs +90 -90
  38. package/src/template/config-template.json +203 -165
  39. package/src/utils/aws-config.js +91 -91
  40. package/src/utils/local-store.js +67 -67
  41. package/src/utils/logger.js +59 -59
package/README.md CHANGED
@@ -1,192 +1,204 @@
1
- # AWS Local Simulator
2
-
3
- [![npm version](https://badge.fury.io/js/aws-local-simulator.svg)](https://badge.fury.io/js/aws-local-simulator)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Node.js Version](https://img.shields.io/node/v/aws-local-simulator.svg)](https://nodejs.org)
6
-
7
- Simulador local completo para serviços AWS. Desenvolva e teste suas aplicações AWS localmente sem custos!
8
-
9
- ## 🚀 Serviços Suportados
10
-
11
- | Serviço | Status | Porta Padrão | Descrição |
12
- |---------|--------|--------------|-----------|
13
- | DynamoDB | ✅ | 8000 | Banco de dados NoSQL |
14
- | S3 | ✅ | 4566 | Armazenamento de objetos |
15
- | SQS | ✅ | 9324 | Filas de mensagens |
16
- | Lambda | ✅ | 3001 | Funções serverless |
17
- | Cognito | ✅ | 9229 | Autenticação e autorização |
18
- | API Gateway | ✅ | 4567 | APIs REST e HTTP |
19
- | ECS/Fargate | 🚧 | 8080 | Orquestração de containers (em desenvolvimento) |
20
- | SNS | 🚧 | 9911 | Notificações (em desenvolvimento) |
21
- | EventBridge | 🚧 | 4010 | Barramento de eventos (em desenvolvimento) |
22
-
23
- ## 📦 Instalação
24
-
25
- ```bash
26
- npm install --save-dev aws-local-simulator
27
- 🚀 Uso Rápido
28
- 1. Crie um arquivo de configuração aws-local-simulator.json:
29
- json
30
- {
31
- "services": {
32
- "dynamodb": true,
33
- "s3": true,
34
- "sqs": true,
35
- "lambda": true,
36
- "cognito": true,
37
- "apigateway": true
38
- },
39
- "lambdas": [
40
- {
41
- "path": "/api/users",
42
- "handler": "./src/handlers/users.js",
43
- "env": {
44
- "TABLE_NAME": "users-table"
45
- }
46
- }
47
- ],
48
- "dynamodb": {
49
- "tables": [
50
- {
51
- "TableName": "users-table",
52
- "KeySchema": [
53
- { "AttributeName": "id", "KeyType": "HASH" }
54
- ],
55
- "AttributeDefinitions": [
56
- { "AttributeName": "id", "AttributeType": "S" }
57
- ]
58
- }
59
- ]
60
- },
61
- "s3": {
62
- "buckets": ["my-bucket"]
63
- },
64
- "cognito": {
65
- "userPools": [
66
- {
67
- "PoolName": "my-user-pool",
68
- "AutoVerifiedAttributes": ["email"]
69
- }
70
- ]
71
- }
72
- }
73
- ```
74
-
75
- # 2. Inicie o simulador:
76
- ## Via CLI
77
- npx aws-local-simulator start
78
-
79
- # Ou via código
80
- const { AWSLocalSimulator } = require('aws-local-simulator');
81
- const simulator = new AWSLocalSimulator();
82
- await simulator.start();
83
-
84
- # 3. Configure seu código para usar os serviços locais:
85
-
86
- ```javascript
87
- // Importe a configuração AWS pronta
88
- const { dynamoDB, s3, sqs, cognito, apigateway } = require('aws-local-simulator/aws-config');
89
-
90
- // Use como normalmente faria
91
- await dynamoDB.send(new PutCommand({
92
- TableName: 'users-table',
93
- Item: { id: '123', name: 'John' }
94
- }));
95
- 🔧 Configuração por Variáveis de Ambiente
96
- Variável Descrição Padrão
97
- AWS_LOCAL_SIMULATOR_DYNAMODB Habilita DynamoDB true
98
- AWS_LOCAL_SIMULATOR_S3 Habilita S3 true
99
- AWS_LOCAL_SIMULATOR_SQS Habilita SQS true
100
- AWS_LOCAL_SIMULATOR_LAMBDA Habilita Lambda true
101
- AWS_LOCAL_SIMULATOR_COGNITO Habilita Cognito false
102
- AWS_LOCAL_SIMULATOR_APIGATEWAY Habilita API Gateway false
103
- AWS_LOCAL_SIMULATOR_ECS Habilita ECS/Fargate false
104
- AWS_LOCAL_SIMULATOR_DYNAMODB_PORT Porta DynamoDB 8000
105
- AWS_LOCAL_SIMULATOR_S3_PORT Porta S3 4566
106
- AWS_LOCAL_SIMULATOR_SQS_PORT Porta SQS 9324
107
- AWS_LOCAL_SIMULATOR_LAMBDA_PORT Porta Lambda 3001
108
- AWS_LOCAL_SIMULATOR_COGNITO_PORT Porta Cognito 9229
109
- AWS_LOCAL_SIMULATOR_APIGATEWAY_PORT Porta API Gateway 4567
110
- AWS_LOCAL_SIMULATOR_ECS_PORT Porta ECS 8080
111
- AWS_LOCAL_SIMULATOR_DATA Diretório de dados ./.aws-local-simulator-data
112
- AWS_LOCAL_SIMULATOR_LOG Nível de log info
113
- ```
114
-
115
- # 📝 Comandos CLI
116
- bash
117
- #### Iniciar simulador
118
- npx aws-local-simulator start [configPath]
119
-
120
- #### Parar simulador
121
- npx aws-local-simulator stop
122
-
123
- #### Reiniciar
124
- npx aws-local-simulator restart
125
-
126
- #### Resetar dados
127
- npx aws-local-simulator reset
128
-
129
- #### Status
130
- npx aws-local-simulator status
131
-
132
- # 🔌 Endpoints
133
- # Serviço Endpoint Admin
134
- DynamoDB http://localhost:8000 http://localhost:8000/__admin/tables
135
- S3 http://localhost:4566 http://localhost:4566/__admin/buckets
136
- SQS http://localhost:9324 http://localhost:9324/__admin/queues
137
- Lambda http://localhost:3001 http://localhost:3001/__admin/lambdas
138
- Cognito http://localhost:9229 http://localhost:9229/__admin/userpools
139
- API Gateway http://localhost:4567 http://localhost:4567/__admin/apis
140
- ECS http://localhost:8080 http://localhost:8080/__admin/clusters
141
- 🧪 Testando com AWS CLI
142
- bash
143
- # DynamoDB
144
- aws dynamodb list-tables --endpoint-url http://localhost:8000
145
-
146
- # S3
147
- aws s3 ls --endpoint-url http://localhost:4566
148
-
149
- # SQS
150
- aws sqs list-queues --endpoint-url http://localhost:9324
151
-
152
- # Cognito
153
- aws cognito-idp list-user-pools --max-results 10 --endpoint-url http://localhost:9229
154
-
155
- # API Gateway
156
- aws apigateway get-rest-apis --endpoint-url http://localhost:4567
157
- 📁 Estrutura de Dados
158
- Os dados são persistidos em:
159
-
160
- text
161
- .aws-local-simulator-data/
162
- ├── dynamodb/
163
- ├── s3/
164
- ├── sqs/
165
- ├── cognito/
166
- ├── apigateway/
167
- └── ecs/
168
- 🐛 Debug
169
- Para logs detalhados:
170
-
171
- bash
172
- AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
173
- 🤝 Contribuindo
174
- Fork o projeto
175
-
176
- Crie sua feature branch (git checkout -b feature/AmazingFeature)
177
-
178
- Commit suas mudanças (git commit -m 'Add some AmazingFeature')
179
-
180
- Push para a branch (git push origin feature/AmazingFeature)
181
-
182
- Abra um Pull Request
183
-
184
- 📄 Licença
185
- MIT © Luiz Gustavo Ribeiro
186
-
187
- ⚠️ Limitações
188
- SNS e EventBridge em desenvolvimento
189
-
190
- WebSocket APIs em desenvolvimento
191
-
192
- Para uso em desenvolvimento e testes apenas
1
+ # AWS Local Simulator
2
+
3
+ [![npm version](https://badge.fury.io/js/aws-local-simulator.svg)](https://badge.fury.io/js/aws-local-simulator)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js Version](https://img.shields.io/node/v/aws-local-simulator.svg)](https://nodejs.org)
6
+
7
+ Simulador local completo para serviços AWS. Desenvolva e teste suas aplicações AWS localmente sem custos!
8
+
9
+ ## 🚀 Serviços Suportados
10
+
11
+ | Serviço | Status | Porta Padrão | Descrição |
12
+ |---------|--------|--------------|-----------|
13
+ | DynamoDB | ✅ | 8000 | Banco de dados NoSQL |
14
+ | S3 | ✅ | 4566 | Armazenamento de objetos |
15
+ | SQS | ✅ | 9324 | Filas de mensagens |
16
+ | Lambda | ✅ | 3001 | Funções serverless |
17
+ | Cognito | ✅ | 9229 | Autenticação e autorização |
18
+ | API Gateway | ✅ | 4567 | APIs REST e HTTP |
19
+ | ECS/Fargate | 🚧 | 8080 | Orquestração de containers (em desenvolvimento) |
20
+ | SNS | 🚧 | 9911 | Notificações (em desenvolvimento) |
21
+ | EventBridge | 🚧 | 4010 | Barramento de eventos (em desenvolvimento) |
22
+
23
+ ## 📦 Instalação
24
+
25
+ ```bash
26
+ npm install --save-dev aws-local-simulator
27
+ ```
28
+ 🚀 Uso Rápido
29
+ 1. Crie um arquivo de configuração aws-local-simulator.json:
30
+ ```json
31
+ {
32
+ "services": {
33
+ "dynamodb": true,
34
+ "s3": true,
35
+ "sqs": true,
36
+ "lambda": true,
37
+ "cognito": true,
38
+ "apigateway": true
39
+ },
40
+ "lambdas": [
41
+ {
42
+ "path": "/api/users",
43
+ "handler": "./src/handlers/users.js",
44
+ "env": {
45
+ "TABLE_NAME": "users-table"
46
+ }
47
+ }
48
+ ],
49
+ "dynamodb": {
50
+ "tables": [
51
+ {
52
+ "TableName": "users-table",
53
+ "KeySchema": [
54
+ { "AttributeName": "id", "KeyType": "HASH" }
55
+ ],
56
+ "AttributeDefinitions": [
57
+ { "AttributeName": "id", "AttributeType": "S" }
58
+ ]
59
+ }
60
+ ]
61
+ },
62
+ "s3": {
63
+ "buckets": ["my-bucket"]
64
+ },
65
+ "cognito": {
66
+ "userPools": [
67
+ {
68
+ "PoolName": "my-user-pool",
69
+ "AutoVerifiedAttributes": ["email"]
70
+ }
71
+ ]
72
+ }
73
+ }
74
+ ```
75
+
76
+ # 2. Inicie o simulador:
77
+ ## Via CLI
78
+ npx aws-local-simulator start
79
+
80
+ # Ou via código
81
+ const { AWSLocalSimulator } = require('aws-local-simulator');
82
+ const simulator = new AWSLocalSimulator();
83
+ await simulator.start();
84
+
85
+ # 3. Configure seu código para usar os serviços locais:
86
+
87
+ ```javascript
88
+ // Importe a configuração AWS pronta
89
+ const { dynamoDB, s3, sqs, cognito, apigateway } = require('aws-local-simulator/aws-config');
90
+
91
+ // Use como normalmente faria
92
+ await dynamoDB.send(new PutCommand({
93
+ TableName: 'users-table',
94
+ Item: { id: '123', name: 'John' }
95
+ }));
96
+ ```
97
+
98
+ 🔧 Configuração por Variáveis de Ambiente
99
+
100
+ | Variável | Descrição | Padrão |
101
+ |---------|----------|-------|
102
+ | AWS_LOCAL_SIMULATOR_DYNAMODB |Habilita DynamoDB | true |
103
+ | AWS_LOCAL_SIMULATOR_S3 |Habilita S3 | true |
104
+ | AWS_LOCAL_SIMULATOR_SQS |Habilita SQS | true |
105
+ | AWS_LOCAL_SIMULATOR_LAMBDA |Habilita Lambda | true |
106
+ | AWS_LOCAL_SIMULATOR_COGNITO |Habilita Cognito | false |
107
+ | AWS_LOCAL_SIMULATOR_APIGATEWAY |Habilita API Gateway | false |
108
+ | AWS_LOCAL_SIMULATOR_ECS |Habilita ECS/Fargate | false |
109
+ | AWS_LOCAL_SIMULATOR_DYNAMODB_PORT |Porta DynamoDB | 8000 |
110
+ | AWS_LOCAL_SIMULATOR_S3_PORT |Porta S3 | 4566 |
111
+ | AWS_LOCAL_SIMULATOR_SQS_PORT |Porta SQS | 9324 |
112
+ | AWS_LOCAL_SIMULATOR_LAMBDA_PORT |Porta Lambda | 3001 |
113
+ | AWS_LOCAL_SIMULATOR_COGNITO_PORT |Porta Cognito | 9229 |
114
+ | AWS_LOCAL_SIMULATOR_APIGATEWAY_PORT |Porta API Gateway | 4567 |
115
+ | AWS_LOCAL_SIMULATOR_ECS_PORT |Porta ECS | 8080 |
116
+ | AWS_LOCAL_SIMULATOR_DATA |Diretório de dados | ./aws-local-simulator-data |
117
+ | AWS_LOCAL_SIMULATOR_LOG |Nível de log | info |
118
+ ```
119
+
120
+ # 📝 Comandos CLI
121
+ ```bash
122
+ #### Iniciar simulador
123
+ npx aws-local-simulator start [configPath]
124
+
125
+ #### Parar simulador
126
+ npx aws-local-simulator stop
127
+
128
+ #### Reiniciar
129
+ npx aws-local-simulator restart
130
+
131
+ #### Resetar dados
132
+ npx aws-local-simulator reset
133
+
134
+ #### Status
135
+ npx aws-local-simulator status
136
+ ```
137
+
138
+ # 🔌 Endpoints
139
+ | Serviço | Endpoint | Admin |
140
+ |---------|----------|-------|
141
+ | DynamoDB | http://localhost:8000 | http://localhost:8000/__admin/tables |
142
+ | S3 | http://localhost:4566 | http://localhost:4566/__admin/buckets |
143
+ | SQS | http://localhost:9324 | http://localhost:9324/__admin/queues |
144
+ | Lambda | http://localhost:3001 | http://localhost:3001/__admin/functions |
145
+ | Cognito | http://localhost:9229 | http://localhost:9229/__admin/userpools |
146
+ | API Gateway | http://localhost:4567 | http://localhost:4567/__admin/apis |
147
+ | ECS | http://localhost:8080 | http://localhost:8080/__admin/clusters |
148
+
149
+ 🧪 Testando com AWS CLI
150
+ ```bash
151
+ # DynamoDB
152
+ aws dynamodb list-tables --endpoint-url http://localhost:8000
153
+
154
+ # S3
155
+ aws s3 ls --endpoint-url http://localhost:4566
156
+
157
+ # SQS
158
+ aws sqs list-queues --endpoint-url http://localhost:9324
159
+
160
+ # Cognito
161
+ aws cognito-idp list-user-pools --max-results 10 --endpoint-url http://localhost:9229
162
+
163
+ # API Gateway
164
+ aws apigateway get-rest-apis --endpoint-url http://localhost:4567
165
+ ```
166
+
167
+ 📁 Estrutura de Dados
168
+ Os dados são persistidos em:
169
+
170
+ ```text
171
+ .aws-local-simulator-data/
172
+ ├── dynamodb/
173
+ ├── s3/
174
+ ├── sqs/
175
+ ├── cognito/
176
+ ├── apigateway/
177
+ └── ecs/
178
+ ```
179
+
180
+ 🐛 Debug
181
+ Para logs detalhados:
182
+
183
+ bash
184
+ AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
185
+ 🤝 Contribuindo
186
+ Fork o projeto
187
+
188
+ Crie sua feature branch (git checkout -b feature/AmazingFeature)
189
+
190
+ Commit suas mudanças (git commit -m 'Add some AmazingFeature')
191
+
192
+ Push para a branch (git push origin feature/AmazingFeature)
193
+
194
+ Abra um Pull Request
195
+
196
+ 📄 Licença
197
+ MIT © Luiz Gustavo Ribeiro
198
+
199
+ ⚠️ Limitações
200
+ SNS e EventBridge em desenvolvimento
201
+
202
+ WebSocket APIs em desenvolvimento
203
+
204
+ Para uso em desenvolvimento e testes apenas
@@ -1,64 +1,64 @@
1
1
  #!/usr/bin/env node
2
-
3
- /**
4
- * CLI para AWS Local Simulator
5
- */
6
-
7
- const { AWSLocalSimulator } = require('../src/index');
8
- const logger = require('../src/utils/logger');
9
- const path = require('path');
10
-
11
- const command = process.argv[2];
12
- const configPath = process.argv[3];
13
-
14
- const simulator = new AWSLocalSimulator({
15
- configPath: configPath ? path.resolve(process.cwd(), configPath) : undefined
16
- });
17
-
18
- async function main() {
19
- switch (command) {
20
- case 'start':
21
- await simulator.start();
22
- break;
23
-
24
- case 'stop':
25
- await simulator.stop();
26
- break;
27
-
28
- case 'restart':
29
- await simulator.restart();
30
- break;
31
-
32
- case 'reset':
33
- await simulator.reset();
34
- break;
35
-
36
- case 'status':
37
- const status = simulator.getStatus();
38
- console.log(JSON.stringify(status, null, 2));
39
- break;
40
-
41
- case 'help':
42
- default:
43
- console.log(`
44
- AWS Local Simulator - CLI Commands:
45
- start [configPath] - Inicia o simulador
46
- stop - Para o simulador
47
- restart - Reinicia o simulador
48
- reset - Reseta todos os dados
49
- status - Mostra status dos serviços
50
- help - Mostra esta ajuda
51
-
52
- Exemplos:
53
- npx aws-local-simulator start
54
- npx aws-local-simulator start ./my-config.json
55
- AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
56
- `);
57
- break;
58
- }
59
- }
60
-
61
- main().catch(error => {
62
- logger.error('Erro:', error);
63
- process.exit(1);
2
+
3
+ /**
4
+ * CLI para AWS Local Simulator
5
+ */
6
+
7
+ const { AWSLocalSimulator } = require('../src/index');
8
+ const logger = require('../src/utils/logger');
9
+ const path = require('path');
10
+
11
+ const command = process.argv[2];
12
+ const configPath = process.argv[3];
13
+
14
+ const simulator = new AWSLocalSimulator({
15
+ configPath: configPath ? path.resolve(process.cwd(), configPath) : undefined
16
+ });
17
+
18
+ async function main() {
19
+ switch (command) {
20
+ case 'start':
21
+ await simulator.start();
22
+ break;
23
+
24
+ case 'stop':
25
+ await simulator.stop();
26
+ break;
27
+
28
+ case 'restart':
29
+ await simulator.restart();
30
+ break;
31
+
32
+ case 'reset':
33
+ await simulator.reset();
34
+ break;
35
+
36
+ case 'status':
37
+ const status = simulator.getStatus();
38
+ console.log(JSON.stringify(status, null, 2));
39
+ break;
40
+
41
+ case 'help':
42
+ default:
43
+ console.log(`
44
+ AWS Local Simulator - CLI Commands:
45
+ start [configPath] - Inicia o simulador
46
+ stop - Para o simulador
47
+ restart - Reinicia o simulador
48
+ reset - Reseta todos os dados
49
+ status - Mostra status dos serviços
50
+ help - Mostra esta ajuda
51
+
52
+ Exemplos:
53
+ npx aws-local-simulator start
54
+ npx aws-local-simulator start ./my-config.json
55
+ AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
56
+ `);
57
+ break;
58
+ }
59
+ }
60
+
61
+ main().catch(error => {
62
+ logger.error('Erro:', error);
63
+ process.exit(1);
64
64
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gugananuvem/aws-local-simulator",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Simulador local completo para serviços AWS",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -109,6 +109,6 @@
109
109
  "optional": true
110
110
  }
111
111
  },
112
- "buildDate": "2026-03-29T02:36:24.504Z",
112
+ "buildDate": "2026-04-03T22:32:50.683Z",
113
113
  "published": true
114
114
  }