Skip to content

Commit

Permalink
Use generated types
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 12, 2023
1 parent ee11423 commit 960176d
Show file tree
Hide file tree
Showing 14 changed files with 747 additions and 79 deletions.
4 changes: 2 additions & 2 deletions src/components/ProductCard/Sub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import { COMMERCIAL_LICENSE_PRODUCT_ID } from "@/util/subs";
import type {
SupabasePrice,
SupabaseProductWithPrice,
SupabaseSubscription,
} from "@/util/supabaseClient";
import { useUser } from "@/util/useUser";
import { Card } from "./Card";
import styles from "./Card.module.css";
import { Tables } from "@/supabase/database.types";

export interface ProductCardProps {
currency: string;
product: SupabaseProductWithPrice;
subscription: SupabaseSubscription | null;
subscription: Tables<"subscriptions"> | null;
}

export function ProductCard({
Expand Down
4 changes: 2 additions & 2 deletions src/components/SubGetStarted/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";

import { COMMERCIAL_LICENSE_PRODUCT_ID } from "@/util/subs";
import { SupabaseSubscription } from "@/util/supabaseClient";
import { GetStartedLicense } from "./GetStartedLicense";
import { GetStartedSaas } from "./GetStartedSaas";
import { SubscriptionWithPrice } from "@/supabase/domain.types";

interface SubGetStartedProps {
subscription: SupabaseSubscription | null; // null means Free Trial
subscription: SubscriptionWithPrice | null; // null means Free Trial
}

export function SubGetStarted({
Expand Down
4 changes: 2 additions & 2 deletions src/pages/api/sendinblue/create-contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { NextApiRequest, NextApiResponse } from "next";

import { sendinblueApi } from "@/util/sendinblue";
import { sentryException } from "@/util/sentry";
import type { SupabaseUser } from "@/util/supabaseClient";
import { getUser, supabaseAdmin } from "@/util/supabaseServer";
import { Tables } from "@/supabase/database.types";

const createContact = async (
req: NextApiRequest,
Expand Down Expand Up @@ -73,7 +73,7 @@ async function updateUserSendinblueContactId(
}

await supabaseAdmin
.from<SupabaseUser>("users")
.from<Tables<"users">>("users")
.update({
sendinblue_contact_id: body.id.toString(),
})
Expand Down
16 changes: 3 additions & 13 deletions src/pages/api/v0/check_email.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { CheckEmailInput, CheckEmailOutput } from "@reacherhq/api";
import type { CheckEmailInput } from "@reacherhq/api";
import { NextApiRequest, NextApiResponse } from "next";
import { v4 } from "uuid";
import amqplib from "amqplib";
import dns from "dns/promises";

import { checkUserInDB, cors } from "@/util/api";
import { checkUserInDB, cors, removeSensitiveData } from "@/util/api";
import { updateSendinblue } from "@/util/sendinblue";
import { sentryException } from "@/util/sentry";
import { SupabaseCall } from "@/util/supabaseClient";
Expand Down Expand Up @@ -188,7 +188,7 @@ export default POST;

// getVerifMethod returns the verifMethod that is best used to verify the
// input's email address.
async function getVerifMethod(input: CheckEmailInput): Promise<string> {
export async function getVerifMethod(input: CheckEmailInput): Promise<string> {
try {
const domain = input.to_email.split("@")[1];
if (!domain) {
Expand Down Expand Up @@ -218,13 +218,3 @@ async function getVerifMethod(input: CheckEmailInput): Promise<string> {
return "Smtp";
}
}

// Remove sensitive data before storing to DB.
function removeSensitiveData(output: CheckEmailOutput): CheckEmailOutput {
const newOutput = { ...output };

// @ts-expect-error - We don't want to store the server name.
delete newOutput.debug?.server_name;

return newOutput;
}
Loading

0 comments on commit 960176d

Please sign in to comment.