fix: resolve TypeScript errors for CI pipeline
- Fix pg-boss Job type imports (PgBoss.Job -> Job from pg-boss) - Replace deprecated teamConcurrency with localConcurrency - Add null checks for possibly undefined values (clients, import rows) - Fix tone type narrowing in profile.ts - Fix test type assertions (non-null assertions, explicit Record types) - Extract auth middleware into shared module - Fix rate limiter Map generic type
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { authMiddleware } from '../middleware/auth';
|
||||
import { Elysia } from 'elysia';
|
||||
import { db } from '../db';
|
||||
import { clients, events, communications } from '../db/schema';
|
||||
@@ -5,6 +6,7 @@ import { eq, and, sql, gte, lte, count, desc } from 'drizzle-orm';
|
||||
import type { User } from '../lib/auth';
|
||||
|
||||
export const reportsRoutes = new Elysia()
|
||||
.use(authMiddleware)
|
||||
// Analytics overview
|
||||
.get('/reports/overview', async ({ user }: { user: User }) => {
|
||||
const userId = user.id;
|
||||
@@ -84,21 +86,21 @@ export const reportsRoutes = new Elysia()
|
||||
|
||||
return {
|
||||
clients: {
|
||||
total: totalClients.count,
|
||||
newThisMonth: newClientsMonth.count,
|
||||
newThisWeek: newClientsWeek.count,
|
||||
contactedRecently: contactedRecently.count,
|
||||
neverContacted: neverContacted.count,
|
||||
total: totalClients?.count ?? 0,
|
||||
newThisMonth: newClientsMonth?.count ?? 0,
|
||||
newThisWeek: newClientsWeek?.count ?? 0,
|
||||
contactedRecently: contactedRecently?.count ?? 0,
|
||||
neverContacted: neverContacted?.count ?? 0,
|
||||
},
|
||||
emails: {
|
||||
total: totalEmails.count,
|
||||
sent: emailsSent.count,
|
||||
draft: emailsDraft.count,
|
||||
sentLast30Days: emailsRecent.count,
|
||||
total: totalEmails?.count ?? 0,
|
||||
sent: emailsSent?.count ?? 0,
|
||||
draft: emailsDraft?.count ?? 0,
|
||||
sentLast30Days: emailsRecent?.count ?? 0,
|
||||
},
|
||||
events: {
|
||||
total: totalEvents.count,
|
||||
upcoming30Days: upcomingEvents.count,
|
||||
total: totalEvents?.count ?? 0,
|
||||
upcoming30Days: upcomingEvents?.count ?? 0,
|
||||
},
|
||||
};
|
||||
})
|
||||
@@ -406,11 +408,11 @@ export const reportsRoutes = new Elysia()
|
||||
});
|
||||
}
|
||||
|
||||
if (draftCount.count > 0) {
|
||||
if ((draftCount?.count ?? 0) > 0) {
|
||||
notifications.push({
|
||||
id: 'drafts',
|
||||
type: 'drafts' as const,
|
||||
title: `${draftCount.count} draft email${draftCount.count > 1 ? 's' : ''} pending`,
|
||||
title: `${draftCount?.count ?? 0} draft email${(draftCount?.count ?? 0) > 1 ? 's' : ''} pending`,
|
||||
description: 'Review and send your drafted emails',
|
||||
date: new Date().toISOString(),
|
||||
link: '/emails',
|
||||
@@ -434,7 +436,7 @@ export const reportsRoutes = new Elysia()
|
||||
overdue: overdueEvents.length,
|
||||
upcoming: upcomingEvents.length,
|
||||
stale: staleClients.length,
|
||||
drafts: draftCount.count,
|
||||
drafts: draftCount?.count ?? 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user