Replace Logger with getLogger and update next version

This commit replaces the use of Logger with getLogger in various parts of the code to handle logging. The Logger has been replaced with getLogger, which assists in getting logs in an asynchronous manner. In addition to this, it updates the next version in pnpm-lock.yaml from next@14.2.0-canary.61 to next@14.2.0-canary.62 and various other dependencies. Also made minor annotations and comments to the function 'isBrowser' and 'formatCurrency' in the 'utils.ts' file.
This commit is contained in:
giancarlo
2024-04-08 12:23:15 +08:00
parent 2b447167f7
commit 9fca45c2de
33 changed files with 369 additions and 250 deletions

View File

@@ -1,6 +1,6 @@
import 'server-only';
import { Logger } from '@kit/shared/logger';
import { getLogger } from '@kit/shared/logger';
import { getSupabaseRouteHandlerClient } from '@kit/supabase/route-handler-client';
import { RecordChange, Tables } from '../record-change.type';
@@ -10,10 +10,12 @@ export class DatabaseWebhookHandlerService {
private readonly namespace = 'database-webhook-handler';
async handleWebhook(request: Request, webhooksSecret: string) {
const logger = await getLogger();
const json = await request.clone().json();
const { table, type } = json as RecordChange<keyof Tables>;
Logger.info(
logger.info(
{
name: this.namespace,
table,
@@ -40,7 +42,7 @@ export class DatabaseWebhookHandlerService {
// handle the webhook event based on the table
await service.handleWebhook(json);
Logger.info(
logger.info(
{
name: this.namespace,
table,
@@ -49,7 +51,7 @@ export class DatabaseWebhookHandlerService {
'Webhook processed successfully',
);
} catch (error) {
Logger.error(
logger.error(
{
name: this.namespace,
table,

View File

@@ -1,6 +1,6 @@
import { SupabaseClient } from '@supabase/supabase-js';
import { Logger } from '@kit/shared/logger';
import { getLogger } from '@kit/shared/logger';
import { Database } from '@kit/supabase/database';
import { RecordChange, Tables } from '../record-change.type';
@@ -8,7 +8,7 @@ import { RecordChange, Tables } from '../record-change.type';
export class DatabaseWebhookRouterService {
constructor(private readonly adminClient: SupabaseClient<Database>) {}
handleWebhook(body: RecordChange<keyof Tables>) {
async handleWebhook(body: RecordChange<keyof Tables>) {
switch (body.table) {
case 'invitations': {
const payload = body as RecordChange<typeof body.table>;
@@ -23,7 +23,9 @@ export class DatabaseWebhookRouterService {
}
default: {
Logger.warn(
const logger = await getLogger();
logger.warn(
{
table: body.table,
},