Skip to content

Commit 13de7bf

Browse files
authored
Merge pull request #183 from lemoncloud-io/feat/json-serialize-uint8array
feat/json-serialize-unit8array
2 parents 04c6937 + 545bf8e commit 13de7bf

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/cores/protocol/protocol-service.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,13 @@ describe('ProtocolService', () => {
211211

212212
//* now verify with real lambda call.
213213
if (PROFILE == 'lemon') {
214-
expect2(await service.execute(param).catch(GETERR)).toEqual(
215-
'Function not found: arn:aws:lambda:ap-northeast-2:085403634746:function:lemon-hello-api-dev-lambda',
216-
);
214+
expect2(await service.execute(param).catch(GETERR)).toEqual('404 NOT FOUND - GET /test/abc');
215+
216+
const helloParam = asParam('', 'hello', { id: undefined });
217+
expect2(await service.execute(helloParam).catch(GETERR)).toEqual({
218+
list: [{ name: 'lemon' }, { name: 'cloud' }],
219+
name: 'lemon',
220+
});
217221
}
218222
});
219223

src/cores/protocol/protocol-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export class MyProtocolService implements ProtocolService {
352352
})
353353
.then((data: InvokeCommandOutput) => {
354354
_log(NS, `! execute[${param.service || ''}].res =`, $U.S(data, 320, 64, ' .... '));
355-
const payload = data && data.Payload ? JSON.parse(`${data.Payload}`) : {};
355+
const payload = data && data?.Payload ? JSON.parse(Buffer.from(data.Payload).toString()) : {};
356356
const statusCode = $U.N(payload.statusCode || (data && data.StatusCode), 200);
357357
_log(NS, `> Lambda[${params.FunctionName}].StatusCode :=`, statusCode);
358358
[200, 201].includes(statusCode) || _inf(NS, `> WARN! status[${statusCode}] data =`, $U.S(data)); // print whole data if not 200.

0 commit comments

Comments
 (0)