Add semi-colons and correct formatting in database.types.ts

This commit implements proper syntax standards throughout the file. Every necessary line now ends with a semicolon, providing better readability and avoiding potential errors in future code interpretation.
This commit is contained in:
giancarlo
2024-04-17 16:15:57 +08:00
parent bf43c48dff
commit a188ca92e1
7 changed files with 2093 additions and 2077 deletions

View File

@@ -275,6 +275,26 @@ STRIPE_WEBHOOK_SECRET=
STRIPE_SECRET_KEY= STRIPE_SECRET_KEY=
``` ```
### Database Webhooks
Finally, you need to set a secret `SUPABASE_DB_WEBHOOK_SECRET` that your server and your Supabase instance will share in order to authenticate the requests.
```
SUPABASE_DB_WEBHOOK_SECRET=**************************************************
```
Make it a strong secret key - and make sure to keep it secret!
Now, you need to deploy the Supabase DB webhooks to your Supabase instance.
Please copy the webhooks (written with Postgres SQL) from apps/web/supabase/seed.sql and make sure to replicate them to the Supabase instance.
Make sure to add the following header `X-Supabase-Webhook-Secret` with the value of the `SUPABASE_DB_WEBHOOK_SECRET` to the request.
In this way - you server will be able to authenticate the request and be sure it's coming from your Supabase instance.
As endpoint, remember to use the `/api/db/webhook` endpoint. If your APP url is `https://myapp.vercel.app`, the endpoint will be `https://myapp.vercel.app/api/db/webhook`.
## Deploying to Vercel ## Deploying to Vercel
Deploying to Vercel is straightforward. You can deploy the application using the Vercel CLI or the Vercel dashboard. Deploying to Vercel is straightforward. You can deploy the application using the Vercel CLI or the Vercel dashboard.

View File

@@ -276,7 +276,7 @@ function HeroTitle({ children }: React.PropsWithChildren) {
return ( return (
<h1 <h1
className={ className={
'font-heading flex flex-col text-center text-5xl font-semibold tracking-tight sm:text-6xl lg:text-7xl' 'flex flex-col text-center font-heading text-5xl font-semibold tracking-tight sm:text-6xl lg:text-7xl'
} }
> >
{children} {children}

View File

@@ -16,10 +16,7 @@ export async function POST(request: Request) {
provider, provider,
}; };
logger.info( logger.info(ctx, `Received billing webhook. Processing...`);
ctx,
`Received billing webhook. Processing...`,
);
const supabaseClientProvider = () => const supabaseClientProvider = () =>
getSupabaseRouteHandlerClient({ admin: true }); getSupabaseRouteHandlerClient({ admin: true });
@@ -33,10 +30,7 @@ export async function POST(request: Request) {
try { try {
await service.handleWebhookEvent(request); await service.handleWebhookEvent(request);
logger.info( logger.info(ctx, `Successfully processed billing webhook`);
ctx,
`Successfully processed billing webhook`,
);
return new Response('OK', { status: 200 }); return new Response('OK', { status: 200 });
} catch (error) { } catch (error) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,18 @@
import { getOrder, getVariant } from '@lemonsqueezy/lemonsqueezy.js'; import { getOrder, getVariant } from '@lemonsqueezy/lemonsqueezy.js';
import {
BillingConfig,
import { BillingConfig, BillingWebhookHandlerService, getLineItemTypeById } from '@kit/billing'; BillingWebhookHandlerService,
getLineItemTypeById,
} from '@kit/billing';
import { getLogger } from '@kit/shared/logger'; import { getLogger } from '@kit/shared/logger';
import { Database } from '@kit/supabase/database'; import { Database } from '@kit/supabase/database';
import { getLemonSqueezyEnv } from '../schema/lemon-squeezy-server-env.schema'; import { getLemonSqueezyEnv } from '../schema/lemon-squeezy-server-env.schema';
import { OrderWebhook } from '../types/order-webhook'; import { OrderWebhook } from '../types/order-webhook';
import { SubscriptionWebhook } from '../types/subscription-webhook'; import { SubscriptionWebhook } from '../types/subscription-webhook';
import { initializeLemonSqueezyClient } from './lemon-squeezy-sdk'; import { initializeLemonSqueezyClient } from './lemon-squeezy-sdk';
import { createHmac } from "./verify-hmac"; import { createHmac } from './verify-hmac';
type UpsertSubscriptionParams = type UpsertSubscriptionParams =
Database['public']['Functions']['upsert_subscription']['Args']; Database['public']['Functions']['upsert_subscription']['Args'];
@@ -419,7 +418,7 @@ async function isSigningSecretValid(rawBody: string, signatureHeader: string) {
const { hex: digest } = await createHmac({ const { hex: digest } = await createHmac({
key: webhooksSecret, key: webhooksSecret,
data: rawBody data: rawBody,
}); });
const signature = Buffer.from(signatureHeader, 'utf8'); const signature = Buffer.from(signatureHeader, 'utf8');

View File

@@ -40,15 +40,20 @@ async function getKeystaticClient() {
return new KeystaticClient(); return new KeystaticClient();
} }
console.error(`[CMS] Keystatic client is only available in Node.js runtime. Please choose a different CMS client. Returning a mock client instead of throwing an error.`); console.error(
`[CMS] Keystatic client is only available in Node.js runtime. Please choose a different CMS client. Returning a mock client instead of throwing an error.`,
);
return mockCMSClient(); return mockCMSClient() as unknown as CmsClient;
} }
function mockCMSClient() { function mockCMSClient() {
return { return {
async getContentItems() { getContentItems() {
return []; return Promise.resolve([]);
},
getContentItemBySlug() {
return Promise.resolve(undefined);
}, },
}; };
} }

File diff suppressed because it is too large Load Diff