Skip to content

Commit abef268

Browse files
committed
fix(ci): resolve compilation, shadowing, unused variable and ESLint failures
1 parent b0314c1 commit abef268

24 files changed

Lines changed: 131 additions & 206 deletions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function makeConnectState(userId: string): string {
4747
function buildConnectApp(mockPrisma: Partial<PrismaClient>) {
4848
const app = Fastify({ logger: false });
4949
app.decorate('prisma', mockPrisma as PrismaClient);
50-
app.decorate('authenticate', async (req: any) => { req.user = { id: USER_ID }; });
50+
app.decorate('authenticate', async (request: any) => { request.user = { id: USER_ID }; });
5151
app.register(connectRoutes, { prefix: '/api/connect' });
5252
return app.ready().then(() => app);
5353
}
@@ -57,7 +57,7 @@ function buildConnectApp(mockPrisma: Partial<PrismaClient>) {
5757
function buildFollowApp(mockPrisma: Partial<PrismaClient>) {
5858
const app = Fastify({ logger: false });
5959
app.decorate('prisma', mockPrisma as PrismaClient);
60-
app.decorate('authenticate', async (req: any) => { req.user = { id: USER_ID }; });
60+
app.decorate('authenticate', async (request: any) => { request.user = { id: USER_ID }; });
6161
app.register(followRoutes, { prefix: '/api/follow' });
6262
return app.ready().then(() => app);
6363
}

apps/backend/src/app.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import helmet from '@fastify/helmet';
77
import jwt from '@fastify/jwt';
88
import multipart from '@fastify/multipart';
99
import rateLimit from '@fastify/rate-limit';
10-
import fastifyStatic from '@fastify/static';
1110
import Fastify, {type FastifyInstance} from 'fastify';
1211

1312
import { prismaPlugin } from './plugins/prisma.js';
@@ -93,7 +92,7 @@ export async function buildApp():Promise<FastifyInstance> {
9392
// Ensure the verified payload is assigned to `request.user` like the original plugin.
9493
const payload = await request.jwtVerify();
9594
if (payload) {request.user = payload;}
96-
} catch (error) {
95+
} catch {
9796
reply.status(401).send({ error: 'Unauthorized' });
9897
}
9998
});

apps/backend/src/env.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import path from 'node:path';
2-
import process from 'node:process';
32
import { fileURLToPath } from 'node:url';
43

54
import dotenv from 'dotenv';

apps/backend/src/plugins/redis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const redisPlugin = fp(async (app: FastifyInstance) => {
1818
try {
1919
await redis.connect();
2020
app.log.info('🔴 Redis connected');
21-
} catch (error) {
21+
} catch {
2222
app.log.warn('⚠️ Redis connection failed — running without cache');
2323
}
2424

apps/backend/src/routes/analytics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function analyticsRoutes(
1212
'/overview',
1313
{
1414

15-
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' }) } }],
15+
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 { reply.status(401).send({ error: 'Unauthorized' }) } }],
1616
},
1717
async (
1818
request: FastifyRequest,
@@ -97,7 +97,7 @@ export async function analyticsRoutes(
9797
'/views',
9898
{
9999

100-
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' }) } }],
100+
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 { reply.status(401).send({ error: 'Unauthorized' }) } }],
101101
},
102102
async (
103103
request: FastifyRequest<{

apps/backend/src/routes/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export async function authRoutes(app: FastifyInstance) {
258258
const server = request.server as any;
259259
if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return }
260260
if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return }
261-
try { await request.jwtVerify() } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }
261+
try { await request.jwtVerify() } catch { reply.status(401).send({ error: 'Unauthorized' }) }
262262
}] }, async (request: FastifyRequest, reply: FastifyReply) => {
263263
const userId = (request.user as any).id;
264264
const user = await app.prisma.user.findUnique({

apps/backend/src/routes/cards.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { handleDbError } from '../utils/error.util.js';
33
import { createCardSchema, updateCardSchema } from '../utils/validators.js';
44

55
import type { Card } from '@devcard/shared';
6-
import type { Prisma } from '@prisma/client';
76
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
87

98

@@ -21,40 +20,16 @@ interface CardParams {
2120
id: string;
2221
}
2322

24-
interface PlatformLink {
25-
id: string;
26-
userId: string;
27-
platform: string;
28-
username: string;
29-
url: string;
30-
displayOrder: number;
31-
createdAt: Date;
32-
}
3323

34-
interface CardLinkWithPlatform {
35-
id: string;
36-
cardId: string;
37-
platformLinkId: string;
38-
displayOrder: number;
39-
platformLink: PlatformLink;
40-
}
4124

42-
interface CardWithLinks {
43-
id: string;
44-
userId: string;
45-
title: string;
46-
isDefault: boolean;
47-
createdAt: Date;
48-
updatedAt: Date;
49-
cardLinks: CardLinkWithPlatform[];
50-
}
25+
5126

5227
export async function cardRoutes(app: FastifyInstance): Promise<void> {
5328
app.addHook('preHandler', async (request, reply) => {
5429
const server = request.server as any;
5530
if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return }
5631
if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return }
57-
try { await request.jwtVerify() } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }
32+
try { await request.jwtVerify() } catch { reply.status(401).send({ error: 'Unauthorized' }) }
5833
});
5934

6035
// ─── List Cards ───

apps/backend/src/routes/connect.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { randomBytes } from 'node:crypto';
2-
3-
import { encrypt } from '../utils/encryption.js';
4-
51
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
2+
import { randomBytes } from 'crypto';
3+
import { encrypt } from '../utils/encryption.js';
64

75
const GITHUB_AUTH_URL = 'https://github.com/login/oauth/authorize';
86
const GITHUB_TOKEN_URL = 'https://github.com/login/oauth/access_token';
@@ -24,17 +22,17 @@ interface ParsedOAuthState {
2422
nonce: string;
2523
}
2624

27-
export async function connectRoutes(app: FastifyInstance) {
25+
export async function connectRoutes(app: FastifyInstance): Promise<void> {
2826
// ─── Status ───
2927

3028
app.get('/status', {
3129
preHandler: [async (request, reply) => {
3230
const server = request.server as any;
3331
if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return }
3432
if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return }
35-
try { await request.jwtVerify() } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }
33+
try { await request.jwtVerify() } catch { reply.status(401).send({ error: 'Unauthorized' }) }
3634
}],
37-
}, async (request: FastifyRequest, reply: FastifyReply) => {
35+
}, async (request: FastifyRequest, _reply: FastifyReply) => {
3836
const userId = (request.user as any).id;
3937

4038
const tokens = await app.prisma.oAuthToken.findMany({
@@ -52,7 +50,7 @@ export async function connectRoutes(app: FastifyInstance) {
5250
const server = request.server as any;
5351
if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return }
5452
if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return }
55-
try { await request.jwtVerify() } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }
53+
try { await request.jwtVerify() } catch { reply.status(401).send({ error: 'Unauthorized' }) }
5654
}],
5755
}, async (request: FastifyRequest, reply: FastifyReply) => {
5856
const userId = (request.user as any).id;
@@ -104,7 +102,7 @@ export async function connectRoutes(app: FastifyInstance) {
104102
}
105103

106104
// Consume the nonce -- one-time use only (if redis configured)
107-
if (app.redis) {await app.redis.del(`oauth:nonce:${decodedState.nonce}`);}
105+
if (app.redis) await app.redis.del(`oauth:nonce:${decodedState.nonce}`);
108106

109107
const userId = decodedState.userId;
110108

@@ -177,7 +175,7 @@ export async function connectRoutes(app: FastifyInstance) {
177175
const server = request.server as any;
178176
if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return }
179177
if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return }
180-
try { await request.jwtVerify() } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }
178+
try { await request.jwtVerify() } catch { reply.status(401).send({ error: 'Unauthorized' }) }
181179
}],
182180
}, async (request: FastifyRequest<{ Params: { platform: string } }>, reply: FastifyReply) => {
183181
const userId = (request.user as any).id;
@@ -198,7 +196,7 @@ export async function connectRoutes(app: FastifyInstance) {
198196
},
199197
});
200198
return { success: true };
201-
} catch (error) {
199+
} catch {
202200
return reply.status(404).send({ error: 'Connection not found' });
203201
}
204202
});

apps/backend/src/routes/event.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {generateUniqueSlug} from '../utils/slug'
2-
import { createEventSchema, joinEventSchema} from '../validations/event.validation';
2+
import { createEventSchema } from '../validations/event.validation';
33

44
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
55

@@ -63,7 +63,7 @@ export async function eventRoutes(app:FastifyInstance) {
6363
const server = request.server as any;
6464
if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return }
6565
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' }) }
66+
try { await request.jwtVerify() } catch { reply.status(401).send({ error: 'Unauthorized' }) }
6767
}] }, async (request: FastifyRequest<{
6868
Body: {
6969
name: string,
@@ -105,7 +105,7 @@ export async function eventRoutes(app:FastifyInstance) {
105105
})
106106

107107
return reply.status(201).send(newEvent);
108-
} catch (error) {
108+
} catch {
109109
app.log.error('Failed to create event');
110110
return reply.status(500).send({error: 'Failed to create event'})
111111
}
@@ -154,7 +154,7 @@ export async function eventRoutes(app:FastifyInstance) {
154154
return response;
155155
})
156156

157-
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) => {
157+
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 { reply.status(401).send({ error: 'Unauthorized' }) } }] }, async(request: FastifyRequest<{Params: {slug: string}}>, reply: FastifyReply) => {
158158
const userId = (request.user as any).id;
159159
const paramsSlug = request.params.slug;
160160

@@ -188,7 +188,7 @@ export async function eventRoutes(app:FastifyInstance) {
188188

189189
})
190190

191-
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) => {
191+
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 { reply.status(401).send({ error: 'Unauthorized' }) } }] }, async(request: FastifyRequest<{Params: {slug: string}}>, reply: FastifyReply) => {
192192
const userId = (request.user as any).id;
193193
const paramsSlug = request.params.slug;
194194

apps/backend/src/routes/follow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { getPlatform, getProfileUrl, getWebViewUrl, resolveDeepLink } from '@devcard/shared';
1+
import { getPlatform, resolveDeepLink } from '@devcard/shared';
22

33
import { decrypt } from '../utils/encryption.js';
44
import { getErrorMessage } from '../utils/error.util.js';
55
import { followLogSchema } from '../validations/follow.validation.js';
66

77
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
88

9-
export async function followRoutes(app: FastifyInstance) {
9+
export async function followRoutes(app: FastifyInstance): Promise<void> {
1010
app.addHook('preHandler', async (request, reply) => {
1111
const server = request.server as any;
1212
if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return }
1313
if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return }
14-
try { const payload = await request.jwtVerify(); if (payload) {(request as any).user = payload;} } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }
14+
try { const payload = await request.jwtVerify(); if (payload) {(request as any).user = payload;} } catch { reply.status(401).send({ error: 'Unauthorized' }) }
1515
});
1616

1717
// ─── Follow via API (Layer 1) ───

0 commit comments

Comments
 (0)