@kirkelliott/zap 0.1.7 → 0.1.9
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/dist/cli.js +29 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -160,6 +160,13 @@ program
|
|
|
160
160
|
const region = cfg.region ?? 'us-east-1';
|
|
161
161
|
const fn = cfg.functionArn ?? cfg.function ?? 'zap-runtime';
|
|
162
162
|
const lambda = new client_lambda_1.LambdaClient({ region });
|
|
163
|
+
try {
|
|
164
|
+
const { Configuration } = await lambda.send(new client_lambda_1.GetFunctionCommand({ FunctionName: fn }));
|
|
165
|
+
console.log(`state: ${Configuration?.State} (${Configuration?.StateReason ?? 'ok'})`);
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
console.log('function: not found -', err.message);
|
|
169
|
+
}
|
|
163
170
|
try {
|
|
164
171
|
const { AuthType, FunctionUrl } = await lambda.send(new client_lambda_1.GetFunctionUrlConfigCommand({ FunctionName: fn }));
|
|
165
172
|
console.log(`url: ${FunctionUrl}`);
|
|
@@ -176,6 +183,28 @@ program
|
|
|
176
183
|
catch (err) {
|
|
177
184
|
console.log('\nresource policy: none -', err.message);
|
|
178
185
|
}
|
|
186
|
+
try {
|
|
187
|
+
const payload = { version: '2.0', rawPath: '/ping', rawQueryString: '', headers: {}, requestContext: { http: { method: 'GET', path: '/ping' } }, isBase64Encoded: false };
|
|
188
|
+
const { Payload, FunctionError } = await lambda.send(new client_lambda_1.InvokeCommand({ FunctionName: fn, Payload: JSON.stringify(payload) }));
|
|
189
|
+
const result = Payload ? JSON.parse(Buffer.from(Payload).toString()) : null;
|
|
190
|
+
console.log(`\ndirect invoke: ${FunctionError ? 'ERROR' : 'ok'}`);
|
|
191
|
+
console.log(JSON.stringify(result, null, 2));
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
console.log('\ndirect invoke failed:', err.message);
|
|
195
|
+
}
|
|
196
|
+
const urlCfg = readConfig();
|
|
197
|
+
if (urlCfg.url) {
|
|
198
|
+
try {
|
|
199
|
+
const res = await fetch(urlCfg.url);
|
|
200
|
+
console.log(`\nurl fetch: HTTP ${res.status}`);
|
|
201
|
+
console.log('headers:', Object.fromEntries([...res.headers.entries()].filter(([k]) => k.startsWith('x-amzn') || k === 'content-type')));
|
|
202
|
+
console.log('body:', await res.text());
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
console.log('\nurl fetch failed:', err.message);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
179
208
|
});
|
|
180
209
|
program
|
|
181
210
|
.command('repair')
|