Update dependencies and improve type safety in webhook handling

This commit updates various dependencies across the project, including a version bump for 'lucide-react' and 'prettier'. Additionally, it improves type safety in the 'database-webhook-handler.service.ts' by making the 'DatabaseChangePayload' and 'handleEvent' function more type-safe.
This commit is contained in:
giancarlo
2024-06-03 00:33:49 +07:00
parent 26b2eed60d
commit 08de59a43a
14 changed files with 138 additions and 74 deletions

View File

@@ -30,7 +30,7 @@
"@supabase/supabase-js": "^2.43.4",
"@types/react": "^18.3.3",
"date-fns": "^3.6.0",
"lucide-react": "^0.381.0",
"lucide-react": "^0.383.0",
"next": "14.2.3",
"react": "18.3.1",
"react-hook-form": "^7.51.4",

View File

@@ -11,7 +11,8 @@ import { getDatabaseWebhookVerifier } from './verifier';
* @name DatabaseChangePayload
* @description Payload for the database change event. Useful for handling custom webhooks.
*/
export type DatabaseChangePayload = RecordChange<keyof Tables>;
export type DatabaseChangePayload<Table extends keyof Tables> =
RecordChange<Table>;
export function getDatabaseWebhookHandlerService() {
return new DatabaseWebhookHandlerService();
@@ -33,7 +34,11 @@ class DatabaseWebhookHandlerService {
async handleWebhook(
request: Request,
params?: {
handleEvent(payload: DatabaseChangePayload): unknown;
handleEvent<Table extends keyof Tables>(
payload: Table extends keyof Tables
? DatabaseChangePayload<Table>
: never,
): unknown;
},
) {
const logger = await getLogger();

View File

@@ -37,7 +37,7 @@
"@tanstack/react-query": "5.40.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"lucide-react": "^0.381.0",
"lucide-react": "^0.383.0",
"next": "14.2.3",
"next-themes": "0.3.0",
"react": "18.3.1",

View File

@@ -24,7 +24,7 @@
"@tanstack/react-query": "5.40.0",
"@tanstack/react-table": "^8.17.3",
"@types/react": "^18.3.3",
"lucide-react": "^0.381.0",
"lucide-react": "^0.383.0",
"next": "14.2.3",
"react": "18.3.1",
"react-dom": "18.3.1",

View File

@@ -31,7 +31,7 @@
"@supabase/supabase-js": "^2.43.4",
"@tanstack/react-query": "5.40.0",
"@types/react": "^18.3.3",
"lucide-react": "^0.381.0",
"lucide-react": "^0.383.0",
"next": "14.2.3",
"react-hook-form": "^7.51.4",
"react-i18next": "^14.1.2",

View File

@@ -23,7 +23,7 @@
"@supabase/supabase-js": "^2.43.4",
"@tanstack/react-query": "5.40.0",
"@types/react": "^18.3.3",
"lucide-react": "^0.381.0",
"lucide-react": "^0.383.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-i18next": "^14.1.2"

View File

@@ -38,7 +38,7 @@
"@types/react-dom": "^18.3.0",
"class-variance-authority": "^0.7.0",
"date-fns": "^3.6.0",
"lucide-react": "^0.381.0",
"lucide-react": "^0.383.0",
"next": "14.2.3",
"react": "18.3.1",
"react-dom": "18.3.1",

View File

@@ -11,8 +11,6 @@ const PROVIDER = getMonitoringProvider();
*/
export async function registerMonitoringInstrumentation() {
if (!PROVIDER) {
console.info(`No instrumentation provider specified. Skipping...`);
return;
}

View File

@@ -31,7 +31,7 @@
"clsx": "^2.1.1",
"cmdk": "1.0.0",
"input-otp": "1.2.4",
"lucide-react": "^0.381.0",
"lucide-react": "^0.383.0",
"react-top-loading-bar": "2.3.1",
"tailwind-merge": "^2.3.0"
},
@@ -49,7 +49,7 @@
"eslint": "^8.57.0",
"next": "14.2.3",
"next-themes": "0.3.0",
"prettier": "^3.2.5",
"prettier": "^3.3.0",
"react-day-picker": "^8.10.1",
"react-hook-form": "^7.51.4",
"react-i18next": "^14.1.2",