This update includes creating new files for the notifications feature along with adding two feature flags for enabling notifications and realtime notifications. All the code and package dependencies required for the notifications functionality have been added. The 'pnpm-lock.yaml' has also been updated due to the inclusion of new package dependencies.
24 lines
611 B
TypeScript
24 lines
611 B
TypeScript
import 'server-only';
|
|
|
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
|
import { Database } from '@kit/supabase/database';
|
|
|
|
type Notification = Database['public']['Tables']['notifications'];
|
|
|
|
export function createNotificationsService(client: SupabaseClient<Database>) {
|
|
return new NotificationsService(client);
|
|
}
|
|
|
|
class NotificationsService {
|
|
constructor(private readonly client: SupabaseClient<Database>) {}
|
|
|
|
async createNotification(params: Notification['Insert']) {
|
|
const { error } = await this.client.from('notifications').insert(params);
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|