Skip to content

Commit bcfeeb8

Browse files
committed
chore: encrypt config
1 parent 3a7d190 commit bcfeeb8

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

packages/stack-forge/src/config/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,28 @@ export async function loadEncryptConfig(
167167
process.exit(1)
168168
}
169169

170-
const encryptClient = Object.values(moduleExports)[0] as EncryptionClient
170+
const encryptClient = Object.values(moduleExports).find(
171+
(value): value is EncryptionClient =>
172+
!!value &&
173+
typeof value === 'object' &&
174+
'getEncryptConfig' in value &&
175+
typeof (value as { getEncryptConfig?: unknown }).getEncryptConfig ===
176+
'function',
177+
)
171178

172179
if (!encryptClient) {
173180
console.error(
174-
`Error: No encrypt client found in ${encryptClientPath}\n\nExport at least one encryptedTable() from your schema file.`,
181+
`Error: No EncryptionClient export found in ${encryptClientPath}.`,
175182
)
176183
process.exit(1)
177184
}
178185

179-
return encryptClient.getEncryptConfig()
186+
const config = encryptClient.getEncryptConfig()
187+
if (!config) {
188+
console.error(
189+
`Error: Encryption client in ${encryptClientPath} has no initialized encrypt config.`,
190+
)
191+
process.exit(1)
192+
}
193+
return config
180194
}

0 commit comments

Comments
 (0)