0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-03 21:48:55 -05:00

refactor(core): remove unnecessary check in github and aliyun-sms connector (#329)

This commit is contained in:
IceHe.xyz 2022-03-07 13:41:28 +08:00 committed by GitHub
parent 3dd7d496ef
commit c42b2a5a67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 12 deletions

View file

@ -68,10 +68,6 @@ const configGuard = z.object({
}); });
export const validateConfig: ValidateConfig = async (config: unknown) => { export const validateConfig: ValidateConfig = async (config: unknown) => {
if (!config) {
throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, 'Missing config');
}
const result = configGuard.safeParse(config); const result = configGuard.safeParse(config);
if (!result.success) { if (!result.success) {

View file

@ -51,10 +51,7 @@ describe('validateConfig', () => {
).resolves.not.toThrow(); ).resolves.not.toThrow();
}); });
it('should throw on empty config', async () => { it('should throw on empty config', async () => {
// FIXME: @sijie await expect(validateConfig({})).rejects.toThrowError();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
await expect(validateConfig()).rejects.toThrowError();
}); });
it('should throw when missing clientSecret', async () => { it('should throw when missing clientSecret', async () => {
await expect(validateConfig({ clientId: 'clientId' })).rejects.toThrowError(); await expect(validateConfig({ clientId: 'clientId' })).rejects.toThrowError();

View file

@ -37,10 +37,6 @@ const githubConfigGuard = z.object({
type GithubConfig = z.infer<typeof githubConfigGuard>; type GithubConfig = z.infer<typeof githubConfigGuard>;
export const validateConfig: ValidateConfig = async (config: unknown) => { export const validateConfig: ValidateConfig = async (config: unknown) => {
if (!config) {
throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, 'Missing config');
}
const result = githubConfigGuard.safeParse(config); const result = githubConfigGuard.safeParse(config);
if (!result.success) { if (!result.success) {