@kirkelliott/zap 0.1.7 → 0.1.8

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 (2) hide show
  1. package/dist/cli.js +17 -0
  2. 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,16 @@ 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
+ }
179
196
  });
180
197
  program
181
198
  .command('repair')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirkelliott/zap",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Drop a .zap file in S3. It becomes an API endpoint.",
5
5
  "main": "dist/handler.js",
6
6
  "bin": {