fix: Resolve TypeScript errors and apply database migration for email-optional

- Add Prisma import for JsonNull filter
- Fix async/await for calculateDistance function
- Install mysql2 for database operations
- Apply ALTER TABLE migration to make email nullable in database
- Verify all tests pass successfully

Tests confirm:
- Users can be created without email
- Notifications work for users without email
- Email sending gracefully skipped when no email present
- Database queries correctly filter by email presence
This commit is contained in:
2025-11-18 18:13:20 +00:00
parent d87ec20714
commit d71c994f0f
3 changed files with 132 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import prisma from '../config/database';
import { Prisma } from '@prisma/client';
import { calculateDistance } from '../utils/spatial';
import { emailService } from './emailService';
@@ -55,7 +56,7 @@ export class NotificationService {
{ notificationInApp: true },
],
areasOfInterest: {
not: null,
not: Prisma.JsonNull,
},
},
select: {
@@ -77,7 +78,7 @@ export class NotificationService {
// Check if the location falls within any of the user's areas of interest
for (const area of areasOfInterest) {
const distance = calculateDistance(
const distance = await calculateDistance(
latitude,
longitude,
area.lat,