Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0656707
changed
aamoghS Jan 21, 2026
a8ff6e1
ok?
aamoghS Jan 21, 2026
5d32e80
update
aamoghS Jan 21, 2026
9d82333
did not push lol
aamoghS Jan 21, 2026
4441053
lazt load
aamoghS Jan 21, 2026
c73bedd
update
aamoghS Jan 21, 2026
b899739
fix
aamoghS Jan 21, 2026
7dde545
idk?
aamoghS Jan 21, 2026
18c8cfa
dude
aamoghS Jan 21, 2026
c9395e8
no way
aamoghS Jan 21, 2026
32d2d8e
um
aamoghS Jan 21, 2026
b38a92e
lol
aamoghS Jan 21, 2026
c5489db
dude
aamoghS Jan 21, 2026
1f497f4
lets try this
aamoghS Jan 21, 2026
9e94b3a
fixxed
aamoghS Jan 21, 2026
9b6cdb8
lol
aamoghS Jan 21, 2026
41e9341
type
aamoghS Jan 21, 2026
118b79e
dude idk
aamoghS Jan 21, 2026
c2418e3
brah
aamoghS Jan 21, 2026
62569f5
e
aamoghS Jan 21, 2026
52e1b02
hello
aamoghS Jan 21, 2026
4ed5a78
no way
aamoghS Jan 21, 2026
9e3b32d
shi gonna crash
aamoghS Jan 21, 2026
3c0af21
lol
aamoghS Jan 21, 2026
751c79a
lol2
aamoghS Jan 21, 2026
5e4b038
another
aamoghS Jan 21, 2026
0628de9
neweser
aamoghS Jan 21, 2026
0b792ba
hello
aamoghS Jan 21, 2026
5fffed3
yoooo
aamoghS Jan 21, 2026
a81fffa
yoooo is ts thing on
aamoghS Jan 21, 2026
70bd3fa
cleaning lol
aamoghS Jan 21, 2026
6794880
extra clean
aamoghS Jan 21, 2026
56eb026
ui chnages
aamoghS Jan 21, 2026
ef4d271
hi
aamoghS Jan 21, 2026
629fbc9
fix 2
aamoghS Jan 21, 2026
7107143
uh
aamoghS Jan 21, 2026
224edb5
fix
aamoghS Jan 21, 2026
907bd61
bruh
aamoghS Jan 21, 2026
d0df5aa
ok lets do it
aamoghS Jan 21, 2026
aaa45c8
uhhh
aamoghS Jan 21, 2026
9d2e168
uhhh
aamoghS Jan 21, 2026
9b69a8d
lol
aamoghS Jan 21, 2026
99c9c1f
fix
aamoghS Jan 21, 2026
ee28508
hi
aamoghS Jan 21, 2026
139e10a
um
aamoghS Jan 22, 2026
08fdd4e
sure
aamoghS Jan 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ coverage
out/
build
dist/
seed-super.ts

# Production
build
Expand All @@ -32,6 +33,7 @@ yarn-error.log*
.env.production

# Vercel
.reset.ts
.vercel

# Turbo
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.0
22.11.0
105 changes: 0 additions & 105 deletions deploy-cloudrun.bat

This file was deleted.

78 changes: 0 additions & 78 deletions deploy-cloudrun.sh

This file was deleted.

4 changes: 2 additions & 2 deletions packages/api/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function getAuth() {
}

export async function createContext(
opts?: FetchCreateContextFnOptions & { clientIp?: string; req?: Request }
opts?: Partial<FetchCreateContextFnOptions> & { clientIp?: string; req?: Request }
) {
let session = null;

Expand All @@ -50,7 +50,7 @@ export async function createContext(
session,
userId: session?.user?.id,
cache,
clientIp: opts?.clientIp || 'unknown',
clientIp: opts?.clientIp || req?.headers.get("x-forwarded-for")?.split(",")[0] || 'unknown',
req
};
}
Expand Down
2 changes: 0 additions & 2 deletions packages/api/src/routers/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { isAdmin, isSuperAdmin } from "../middleware/procedures";

export const adminRouter = createTRPCRouter({
isAdmin: protectedProcedure.query(async ({ ctx }) => {
// Check cache first
const cacheKey = CacheKeys.admin(ctx.userId!);
const cached = ctx.cache.get<{
isAdmin: boolean;
Expand All @@ -30,7 +29,6 @@ export const adminRouter = createTRPCRouter({
permissions: admin?.permissions || [],
};

// Cache for 60 seconds
ctx.cache.set(cacheKey, result, 60);

return result;
Expand Down
14 changes: 0 additions & 14 deletions packages/api/src/routers/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { randomUUID } from "crypto";
import { isAdmin } from "../middleware/procedures";

export const eventRouter = createTRPCRouter({
// ADMIN: Create event
create: isAdmin
.input(
z.object({
Expand All @@ -33,7 +32,6 @@ export const eventRouter = createTRPCRouter({
return newEvent;
}),

// ADMIN: Regenerate QR code for an event
regenerateQR: isAdmin
.input(z.object({ eventId: z.string().uuid() }))
.mutation(async ({ ctx, input }) => {
Expand All @@ -58,7 +56,6 @@ export const eventRouter = createTRPCRouter({
return updatedEvent;
}),

// ADMIN: List all events
listAll: isAdmin.query(async ({ ctx }) => {
const allEvents = await ctx.db!.query.events.findMany({
orderBy: (events, { desc }) => [desc(events.eventDate)],
Expand All @@ -76,7 +73,6 @@ export const eventRouter = createTRPCRouter({
return allEvents;
}),

// ADMIN: Get event with check-ins
getById: isAdmin
.input(z.object({ id: z.string().uuid() }))
.query(async ({ ctx, input }) => {
Expand Down Expand Up @@ -115,7 +111,6 @@ export const eventRouter = createTRPCRouter({
return event;
}),

// ADMIN: Toggle check-in enabled
toggleCheckIn: isAdmin
.input(
z.object({
Expand All @@ -136,21 +131,17 @@ export const eventRouter = createTRPCRouter({
return updatedEvent;
}),

// ADMIN: Delete event
delete: isAdmin
.input(z.object({ eventId: z.string().uuid() }))
.mutation(async ({ ctx, input }) => {
await ctx.db!.delete(events).where(eq(events.id, input.eventId));
return { success: true };
}),

// MEMBER: Check in to event via QR code (OPTIMIZED - Single Query)
checkIn: protectedProcedure
.input(z.object({ qrCode: z.string().uuid() }))
.mutation(async ({ ctx, input }) => {
// Single transaction with all checks and inserts
return await ctx.db!.transaction(async (tx) => {
// 1. Get event and validate in one query
const event = await tx.query.events.findFirst({
where: eq(events.qrCode, input.qrCode),
});
Expand All @@ -169,15 +160,13 @@ export const eventRouter = createTRPCRouter({
});
}

// 2. Check max capacity
if (event.maxCheckIns && event.currentCheckIns >= event.maxCheckIns) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Event is full",
});
}

// 3. Get member and check for existing check-in in parallel
const [member, existingCheckIn] = await Promise.all([
tx.query.members.findFirst({
where: eq(members.userId, ctx.userId!),
Expand All @@ -204,7 +193,6 @@ export const eventRouter = createTRPCRouter({
});
}

// 4. Create check-in and update counter
await Promise.all([
tx.insert(eventCheckIns).values({
eventId: event.id,
Expand All @@ -227,7 +215,6 @@ export const eventRouter = createTRPCRouter({
});
}),

// MEMBER: Get my attended events
myEvents: protectedProcedure.query(async ({ ctx }) => {
const checkIns = await ctx.db!.query.eventCheckIns.findMany({
where: eq(eventCheckIns.userId, ctx.userId!),
Expand All @@ -249,7 +236,6 @@ export const eventRouter = createTRPCRouter({
return checkIns;
}),

// MEMBER: Get my stats (OPTIMIZED - Single Aggregation Query)
myStats: protectedProcedure.query(async ({ ctx }) => {
const result = await ctx.db!
.select({
Expand Down
7 changes: 0 additions & 7 deletions packages/api/src/routers/hackathon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const hackathonRouter = createTRPCRouter({
})
)
.query(async ({ ctx, input }) => {
// Generate cache key based on input parameters
const cacheKey = `hackathons:list:${input.status || 'all'}:${input.upcoming ? 'upcoming' : 'all'}:${input.limit}:${input.offset}`;

// Check cache first
Expand All @@ -43,7 +42,6 @@ export const hackathonRouter = createTRPCRouter({
orderBy: (hackathons, { desc }) => [desc(hackathons.startDate)],
});

// Cache for 60 seconds (hackathon lists don't change often)
ctx.cache.set(cacheKey, allHackathons, 60);

return allHackathons;
Expand All @@ -68,7 +66,6 @@ export const hackathonRouter = createTRPCRouter({
});
}

// Cache for 120 seconds
ctx.cache.set(cacheKey, hackathon, 120);

return hackathon;
Expand Down Expand Up @@ -109,7 +106,6 @@ export const hackathonRouter = createTRPCRouter({
})
.returning();

// Invalidate hackathon list cache
ctx.cache.deletePattern('hackathons:*');

return newHackathon;
Expand Down Expand Up @@ -143,7 +139,6 @@ export const hackathonRouter = createTRPCRouter({
.mutation(async ({ ctx, input }) => {
const { id, ...updateData } = input;

// Verify hackathon exists
const existing = await ctx.db!.query.hackathons.findFirst({
where: eq(hackathons.id, id),
});
Expand All @@ -164,7 +159,6 @@ export const hackathonRouter = createTRPCRouter({
.where(eq(hackathons.id, id))
.returning();

// Invalidate hackathon caches
ctx.cache.delete(CacheKeys.hackathon(id));
ctx.cache.deletePattern('hackathons:*');

Expand All @@ -182,7 +176,6 @@ export const hackathonRouter = createTRPCRouter({
})
)
.mutation(async ({ ctx, input }) => {
// Use transaction to prevent race conditions
return await ctx.db!.transaction(async (tx) => {
const hackathon = await tx.query.hackathons.findFirst({
where: eq(hackathons.id, input.hackathonId),
Expand Down
Loading