0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

chore(connector): update the parse of email usage api response (#4201)

This commit is contained in:
Darcy Ye 2023-07-21 13:52:32 +08:00 committed by GitHub
parent 088efeef1a
commit 474cc4c2c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
import { assert } from '@silverhand/essentials';
import { HTTPError, got } from 'got';
import { z } from 'zod';
import type {
CreateConnector,
@ -13,6 +14,7 @@ import {
validateConfig,
ConnectorError,
ConnectorErrorCodes,
parseJson,
} from '@logto/connector-kit';
import { defaultMetadata, defaultTimeout, emailEndpoint, usageEndpoint } from './constant.js';
@ -101,7 +103,7 @@ const getUsage =
},
});
return Number(httpResponse.body);
return z.object({ count: z.number() }).parse(parseJson(httpResponse.body)).count;
};
const createLogtoEmailConnector: CreateConnector<EmailConnector> = async ({ getConfig }) => {