@gugananuvem/aws-local-simulator 1.0.10 → 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 -193
  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 -68
  7. package/src/index.js +130 -130
  8. package/src/index.mjs +123 -123
  9. package/src/server.js +221 -222
  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 +65 -65
  20. package/src/services/ecs/server.js +233 -233
  21. package/src/services/ecs/simulator.js +844 -844
  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 -284
  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 -203
  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,193 +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
- ```
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
- 🔧 Configuração por Variáveis de Ambiente
97
- Variável Descrição Padrão
98
- AWS_LOCAL_SIMULATOR_DYNAMODB Habilita DynamoDB true
99
- AWS_LOCAL_SIMULATOR_S3 Habilita S3 true
100
- AWS_LOCAL_SIMULATOR_SQS Habilita SQS true
101
- AWS_LOCAL_SIMULATOR_LAMBDA Habilita Lambda true
102
- AWS_LOCAL_SIMULATOR_COGNITO Habilita Cognito false
103
- AWS_LOCAL_SIMULATOR_APIGATEWAY Habilita API Gateway false
104
- AWS_LOCAL_SIMULATOR_ECS Habilita ECS/Fargate false
105
- AWS_LOCAL_SIMULATOR_DYNAMODB_PORT Porta DynamoDB 8000
106
- AWS_LOCAL_SIMULATOR_S3_PORT Porta S3 4566
107
- AWS_LOCAL_SIMULATOR_SQS_PORT Porta SQS 9324
108
- AWS_LOCAL_SIMULATOR_LAMBDA_PORT Porta Lambda 3001
109
- AWS_LOCAL_SIMULATOR_COGNITO_PORT Porta Cognito 9229
110
- AWS_LOCAL_SIMULATOR_APIGATEWAY_PORT Porta API Gateway 4567
111
- AWS_LOCAL_SIMULATOR_ECS_PORT Porta ECS 8080
112
- AWS_LOCAL_SIMULATOR_DATA Diretório de dados ./.aws-local-simulator-data
113
- AWS_LOCAL_SIMULATOR_LOG Nível de log info
114
- ```
115
-
116
- # 📝 Comandos CLI
117
- bash
118
- #### Iniciar simulador
119
- npx aws-local-simulator start [configPath]
120
-
121
- #### Parar simulador
122
- npx aws-local-simulator stop
123
-
124
- #### Reiniciar
125
- npx aws-local-simulator restart
126
-
127
- #### Resetar dados
128
- npx aws-local-simulator reset
129
-
130
- #### Status
131
- npx aws-local-simulator status
132
-
133
- # 🔌 Endpoints
134
- # Serviço Endpoint Admin
135
- DynamoDB http://localhost:8000 http://localhost:8000/__admin/tables
136
- S3 http://localhost:4566 http://localhost:4566/__admin/buckets
137
- SQS http://localhost:9324 http://localhost:9324/__admin/queues
138
- Lambda http://localhost:3001 http://localhost:3001/__admin/lambdas
139
- Cognito http://localhost:9229 http://localhost:9229/__admin/userpools
140
- API Gateway http://localhost:4567 http://localhost:4567/__admin/apis
141
- ECS http://localhost:8080 http://localhost:8080/__admin/clusters
142
- 🧪 Testando com AWS CLI
143
- bash
144
- # DynamoDB
145
- aws dynamodb list-tables --endpoint-url http://localhost:8000
146
-
147
- # S3
148
- aws s3 ls --endpoint-url http://localhost:4566
149
-
150
- # SQS
151
- aws sqs list-queues --endpoint-url http://localhost:9324
152
-
153
- # Cognito
154
- aws cognito-idp list-user-pools --max-results 10 --endpoint-url http://localhost:9229
155
-
156
- # API Gateway
157
- aws apigateway get-rest-apis --endpoint-url http://localhost:4567
158
- 📁 Estrutura de Dados
159
- Os dados são persistidos em:
160
-
161
- text
162
- .aws-local-simulator-data/
163
- ├── dynamodb/
164
- ├── s3/
165
- ├── sqs/
166
- ├── cognito/
167
- ├── apigateway/
168
- └── ecs/
169
- 🐛 Debug
170
- Para logs detalhados:
171
-
172
- bash
173
- AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
174
- 🤝 Contribuindo
175
- Fork o projeto
176
-
177
- Crie sua feature branch (git checkout -b feature/AmazingFeature)
178
-
179
- Commit suas mudanças (git commit -m 'Add some AmazingFeature')
180
-
181
- Push para a branch (git push origin feature/AmazingFeature)
182
-
183
- Abra um Pull Request
184
-
185
- 📄 Licença
186
- MIT © Luiz Gustavo Ribeiro
187
-
188
- ⚠️ Limitações
189
- SNS e EventBridge em desenvolvimento
190
-
191
- WebSocket APIs em desenvolvimento
192
-
193
- 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.10",
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-29T15:37:11.579Z",
112
+ "buildDate": "2026-04-03T22:32:50.683Z",
113
113
  "published": true
114
114
  }