Skip to content

Commit 3d9eda4

Browse files
author
Amrit
committed
fix(backend): resolve tsc errors and eslint violations after merge
1 parent 65bfdb0 commit 3d9eda4

19 files changed

Lines changed: 67 additions & 55 deletions

apps/backend/src/__tests__/analytics.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import Fastify, {
2+
type FastifyInstance,
3+
} from 'fastify';
14
import {
25
describe,
36
it,
@@ -7,13 +10,11 @@ import {
710
vi,
811
} from 'vitest';
912

10-
import Fastify, {
11-
type FastifyInstance,
12-
} from 'fastify';
13+
14+
import { analyticsRoutes } from '../routes/analytics';
1315

1416
import type { PrismaClient } from '@prisma/client';
1517

16-
import { analyticsRoutes } from '../routes/analytics';
1718

1819
// ─── Shared mock data ────────────────────────────────────────────────────────
1920

@@ -35,7 +36,7 @@ const prismaMock = {
3536

3637
// ─── App factory ─────────────────────────────────────────────────────────────
3738

38-
let mockJwtVerify = vi.fn();
39+
const mockJwtVerify = vi.fn();
3940

4041
async function buildApp(): Promise<FastifyInstance> {
4142
const app = Fastify({

apps/backend/src/__tests__/event.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import Fastify, { type FastifyInstance } from 'fastify';
12
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
2-
import Fastify, { FastifyInstance } from 'fastify';
3-
import { PrismaClient } from '@prisma/client';
3+
44
import { eventRoutes } from '../routes/event';
55

6+
import type { PrismaClient } from '@prisma/client';
7+
68
// ─── Shared mock data ────────────────────────────────────────────────────────
79

810
const MOCK_USER_ID = 'user-uuid-001';
@@ -68,7 +70,7 @@ const prismaMock = {
6870
//
6971
// This mirrors the real app setup without touching a real DB or real JWT keys.
7072

71-
let mockJwtVerify = vi.fn();
73+
const mockJwtVerify = vi.fn();
7274

7375
async function buildApp(): Promise<FastifyInstance> {
7476
const app = Fastify({ logger: false });

apps/backend/src/__tests__/follow.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Fastify, { FastifyInstance } from 'fastify';
1+
import Fastify, { type FastifyInstance } from 'fastify';
22
import { describe, expect, it, vi, beforeAll, beforeEach, afterAll } from 'vitest';
33

44
import { followRoutes } from '../routes/follow.js';

apps/backend/src/__tests__/oauth-scope.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-param-reassign */
12
/**
23
* Regression tests for OAuth token scope isolation.
34
*
@@ -11,10 +12,12 @@
1112
* flow so the two records are independent and can never overwrite each other.
1213
*/
1314

14-
import { describe, it, expect, beforeEach, vi } from 'vitest';
1515
import Fastify from 'fastify';
16+
import { describe, it, expect, beforeEach, vi } from 'vitest';
17+
1618
import { connectRoutes } from '../routes/connect.js';
1719
import { followRoutes } from '../routes/follow.js';
20+
1821
import type { PrismaClient } from '@prisma/client';
1922

2023
// ── Mocks ─────────────────────────────────────────────────────────────────────

apps/backend/src/__tests__/team.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { type PrismaClient, TeamRole } from '@prisma/client';
2+
import Fastify, { type FastifyInstance } from 'fastify';
13
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
2-
import Fastify, { FastifyInstance } from 'fastify';
3-
import { PrismaClient, TeamRole } from '@prisma/client';
4+
45
import { teamRoutes } from '../routes/team';
56

67
// ─── Shared mock data ─────────────────────────────────────────────────────────
@@ -92,7 +93,7 @@ const prismaMock = {
9293

9394
// ─── App factory ──────────────────────────────────────────────────────────────
9495

95-
let mockJwtVerify = vi.fn();
96+
const mockJwtVerify = vi.fn();
9697

9798
async function buildApp(): Promise<FastifyInstance> {
9899
const app = Fastify({ logger: false });

apps/backend/src/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import process from 'node:process';
21
import path from 'node:path';
32
import { fileURLToPath } from 'node:url';
3+
44
import dotenv from 'dotenv';
55

66
const __dirname = path.dirname(fileURLToPath(import.meta.url));

apps/backend/src/plugins/prisma.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import fp from 'fastify-plugin';
21
import { PrismaClient } from '@prisma/client';
2+
import fp from 'fastify-plugin';
3+
34
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
45

56
declare module 'fastify' {

apps/backend/src/plugins/redis.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fp from 'fastify-plugin';
22
import Redis from 'ioredis';
3+
34
import type { FastifyInstance } from 'fastify';
45

56
declare module 'fastify' {
@@ -17,7 +18,7 @@ export const redisPlugin = fp(async (app: FastifyInstance) => {
1718
try {
1819
await redis.connect();
1920
app.log.info('🔴 Redis connected');
20-
} catch (error) {
21+
} catch (_error) {
2122
app.log.warn('⚠️ Redis connection failed — running without cache');
2223
}
2324

apps/backend/src/routes/event.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import {generateUniqueSlug} from '../utils/slug.js'
2+
import { createEventSchema } from '../validations/event.validation.js';
3+
14
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
2-
import { createEventSchema, joinEventSchema} from '../validations/event.validation.js';
35

4-
import {generateUniqueSlug} from '../utils/slug.js'
56

67

78
type EventDetails = {
@@ -63,7 +64,7 @@ export async function eventRoutes(app:FastifyInstance) {
6364
const server = request.server as any;
6465
if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return }
6566
if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return }
66-
try { await request.jwtVerify() } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }
67+
try { await request.jwtVerify() } catch (_e) { reply.status(401).send({ error: 'Unauthorized' }) }
6768
}] }, async (request: FastifyRequest<{
6869
Body: {
6970
name: string,
@@ -81,8 +82,8 @@ export async function eventRoutes(app:FastifyInstance) {
8182

8283
const {name, description, startDate, endDate, isPublic ,location} = parsed.data
8384

84-
let finalSlug = await generateUniqueSlug(name, async(slug) => {
85-
const existing = await app.prisma.event.findUnique({where: {slug : slug}})
85+
const finalSlug = await generateUniqueSlug(name, async(slug) => {
86+
const existing = await app.prisma.event.findUnique({where: {slug}})
8687

8788
return !!existing
8889
})
@@ -96,7 +97,7 @@ export async function eventRoutes(app:FastifyInstance) {
9697
name,
9798
description,
9899
slug: finalSlug,
99-
location: location,
100+
location,
100101
startDate: startDateObj,
101102
endDate: endDateObj,
102103
isPublic: isPublic ?? true,
@@ -105,7 +106,7 @@ export async function eventRoutes(app:FastifyInstance) {
105106
})
106107

107108
return reply.status(201).send(newEvent);
108-
} catch (error) {
109+
} catch (_error) {
109110
app.log.error('Failed to create event');
110111
return reply.status(500).send({error: 'Failed to create event'})
111112
}
@@ -155,7 +156,7 @@ export async function eventRoutes(app:FastifyInstance) {
155156
return response;
156157
})
157158

158-
app.post('/:slug/join', { preHandler: [async (request, reply) => { const server = request.server as any; if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return } if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return } try { await request.jwtVerify() } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) } }] }, async(request: FastifyRequest<{Params: {slug: string}}>, reply: FastifyReply) => {
159+
app.post('/:slug/join', { preHandler: [async (request, reply) => { const server = request.server as any; if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return } if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return } try { await request.jwtVerify() } catch (_e) { reply.status(401).send({ error: 'Unauthorized' }) } }] }, async(request: FastifyRequest<{Params: {slug: string}}>, reply: FastifyReply) => {
159160
const userId = (request.user as any).id;
160161
const paramsSlug = request.params.slug;
161162

@@ -173,7 +174,7 @@ export async function eventRoutes(app:FastifyInstance) {
173174
await app.prisma.eventAttendee.create({
174175
data: {
175176
eventId: event.id,
176-
userId: userId,
177+
userId,
177178
joinedAt: new Date()
178179
}
179180
})
@@ -189,7 +190,7 @@ export async function eventRoutes(app:FastifyInstance) {
189190

190191
})
191192

192-
app.delete('/:slug/leave', { preHandler: [async (request, reply) => { const server = request.server as any; if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return } if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return } try { await request.jwtVerify() } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) } }] }, async(request: FastifyRequest<{Params: {slug: string}}>, reply: FastifyReply) => {
193+
app.delete('/:slug/leave', { preHandler: [async (request, reply) => { const server = request.server as any; if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return } if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return } try { await request.jwtVerify() } catch (_e) { reply.status(401).send({ error: 'Unauthorized' }) } }] }, async(request: FastifyRequest<{Params: {slug: string}}>, reply: FastifyReply) => {
193194
const userId = (request.user as any).id;
194195
const paramsSlug = request.params.slug;
195196

@@ -207,7 +208,7 @@ export async function eventRoutes(app:FastifyInstance) {
207208
await app.prisma.eventAttendee.delete({
208209
where: {
209210
userId_eventId: {
210-
userId: userId,
211+
userId,
211212
eventId: event.id
212213
}
213214
}

apps/backend/src/routes/nfc.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
21
import { z } from 'zod';
32

3+
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
4+
45
type NfcPayloadResponse = {
56
type: 'URI';
67
payload: string;
@@ -23,7 +24,7 @@ export async function nfcRoutes(app: FastifyInstance) {
2324
}
2425
try {
2526
await request.jwtVerify();
26-
} catch (e) {
27+
} catch (_e) {
2728
reply.status(401).send({ error: 'Unauthorized' });
2829
}
2930
});

0 commit comments

Comments
 (0)