Skip to content

Commit

Permalink
remove unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
jojo-stripe committed Jul 12, 2024
1 parent 5805f71 commit c59c91c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ function getRandomInt(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

function assertUnreachable(x: never | undefined, message?: string) {
console.error(
message ?? 'Thing that should never be set is set',
JSON.parse(JSON.stringify(x))
);
}

export const authOptions: AuthOptions = {
session: {
strategy: 'jwt',
Expand Down Expand Up @@ -389,14 +382,14 @@ export const authOptions: AuthOptions = {
console.log('Could not find an existing user for the email', email);
return null;
}
let businessType: Stripe.Account.BusinessType;
let businessType;
switch (credentials?.businessType) {
case 'company':
case 'individual':
businessType = credentials?.businessType;
businessType =
credentials?.businessType as Stripe.AccountCreateParams.BusinessType;
default:
assertUnreachable(credentials?.businessType);
businessType = 'individual'; // We default to individual, but rely on TS to catch missing cases
businessType = undefined; // We default to undefined so user can pick the business type during onboarding
}

console.log('Creating stripe account for the email', email);
Expand Down

0 comments on commit c59c91c

Please sign in to comment.