Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.16
v25.6.1
1 change: 1 addition & 0 deletions apps/blade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@forge/db": "workspace:*",
"@forge/email": "workspace:^",
"@forge/ui": "workspace:*",
"@forge/utils": "workspace:*",
"@forge/validators": "workspace:*",
"@react-email/render": "1.1.0",
"@stripe/react-stripe-js": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function Attendees({ eventId }: { eventId: string }) {
}

invalidateAttendees().catch((error) => {
// TODO: look into not using the console
// eslint-disable-next-line no-console
console.error(
"Error invalidating members in gathering attendees: ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function MemberProfileButton({
}

invalidateMembers().catch((error) => {
// TODO: why are we logging to the browser console
// eslint-disable-next-line no-console
console.error("Error invalidating members in member profile: ", error);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function Attendees({ eventId }: { eventId: string }) {
}

invalidateAttendees().catch((error) => {
// TODO: look into not logging into the console
// eslint-disable-next-line no-console
console.error(
"Error invalidating members in gathering attendees: ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function QRCodesClient() {
setSelectedRoom(null);
} catch (err: unknown) {
const message = err instanceof Error ? err.message : String(err);
// TODO: look into not logging into the console
// eslint-disable-next-line no-console
console.error("Failed to generate room:", err);
alert(`Failed to generate room: ${message}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ export function HackerFormPage({
},
});
} catch (error) {
// TODO: look into not logging into the console
// eslint-disable-next-line no-console
console.error("Error uploading resume or creating hacker:", error);
toast.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ export function DownloadQRPass() {

toast.success("Apple Wallet pass downloaded successfully!");
} catch (error) {
// TODO: look into not logging into the console
console.error("Error downloading pass:", error); // eslint-disable-line no-console
toast.error("Failed to download pass");
} finally {
setIsDownloading(false);
}
},
onError: (error: { message?: string }) => {
// TODO: look into not logging into the console
console.error("Error generating pass:", error); // eslint-disable-line no-console
toast.error(error.message ?? "Failed to generate pass");
setIsDownloading(false);
Expand Down
6 changes: 3 additions & 3 deletions apps/blade/src/app/_components/forms/connection-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { stringify } from "superjson";

import { appRouter } from "@forge/api";
import { log } from "@forge/api/utils";
import { auth } from "@forge/auth/server";
import { discord } from "@forge/utils";

import { extractProcedures } from "~/lib/utils";
import { api } from "~/trpc/server";
Expand Down Expand Up @@ -46,15 +46,15 @@ export const handleCallbacks = async (

try {
await proc(data);
await log({
await discord.log({
title: `Successfully automatically fired procedure`,
message: `**Successfully fired procedure**\n\`${con.proc}\`\n\nTriggered after **${name}** submission from **${session.user.name}**`,
color: "success_green",
userId: session.user.discordUserId,
});
} catch (error) {
const errorMessage = JSON.stringify(error, null, 2);
await log({
await discord.log({
title: `Failed to automatically fire procedure`,
message:
`**Failed to fire procedure**\n\`${con.proc}\`\n\nTriggered after **${name}** submission from **${session.user.name}**\n\n**Data:**\n\`\`\`json\n${stringify(data)}\`\`\`` +
Expand Down
10 changes: 5 additions & 5 deletions apps/blade/src/app/api/membership/route.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* eslint-disable no-console */
import type { NextRequest } from "next/server";
import Stripe from "stripe";

import { db } from "@forge/db/client";
import { DuesPayment, DuesPaymentSchema } from "@forge/db/schemas/knight-hacks";
import { logger } from "@forge/utils";

import { env } from "~/env";

async function membershipRecord(sessionId: string) {
const stripe = new Stripe(env.STRIPE_SECRET_KEY, { typescript: true });

// TODO: Make this function safe to run multiple times,
// even concurrently, with the same session ID
// even concurrently, with the same session ID

// TODO: Make sure fulfillment hasn't already been
// peformed for this Checkout Session
// peformed for this Checkout Session

// Retrieve the Checkout Session from the API
try {
Expand All @@ -32,7 +32,7 @@ async function membershipRecord(sessionId: string) {
}).safeParse(values);

if (!validatedCheckoutFields.success) {
console.log(validatedCheckoutFields.error.issues);
logger.log(validatedCheckoutFields.error.issues);
throw new Error("Invalid or missing field(s)");
}
// Check the Checkout Session's payment_status property
Expand All @@ -43,7 +43,7 @@ async function membershipRecord(sessionId: string) {
}
throw new Error("Checkout session payment status is unpaid");
} catch (e) {
console.error("Error:", e);
logger.error("Error:", e);
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions apps/blade/src/app/api/trpc/[trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const handler = async (req: Request) => {
headers: req.headers,
}),
onError({ error, path }) {
// TODO: look into not logging into the console
// eslint-disable-next-line no-console
console.error(`>>> tRPC Error on '${path}'`, error.message);
},
Expand Down
4 changes: 2 additions & 2 deletions apps/blade/src/app/judge/session/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// apps/blade/app/api/judge/session/route.ts
import { NextResponse } from "next/server";

import { getJudgeSessionFromCookie } from "../../../../../../packages/api/src/utils";
import { permissions } from "@forge/utils";

export async function GET() {
const row = await getJudgeSessionFromCookie();
const row = await permissions.getJudgeSessionFromCookie();
if (!row) return NextResponse.json({ ok: false }, { status: 401 });
return NextResponse.json({ ok: true, roomName: row.roomName });
}
1 change: 1 addition & 0 deletions apps/club/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@forge/consts": "workspace:*",
"@forge/db": "workspace:*",
"@forge/ui": "workspace:*",
"@forge/utils": "workspace:*",
"@gsap/react": "^2.1.2",
"@svgr/webpack": "^8.1.0",
"framer-motion": "^12.0.1",
Expand Down
1 change: 1 addition & 0 deletions apps/club/src/app/_components/contact/contact-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function ContactForm() {
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
const jsonFormData = JSON.stringify(formData);
// TODO: look into not logging into the console
// eslint-disable-next-line no-console
console.log("The Form:", jsonFormData);
};
Expand Down
6 changes: 4 additions & 2 deletions apps/club/src/app/_components/landing/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { Calendar, List } from "rsuite";
import type { RouterOutputs } from "@forge/api";
import type { ReturnEvent } from "@forge/db/schemas/knight-hacks";

import { formatDateRange } from "~/lib/utils";
import NeonTkSVG from "./assets/neon-tk";
import SwordSVG from "./assets/sword";
import TerminalSVG from "./assets/terminal";

import "rsuite/Calendar/styles/index.css";

import { time } from "@forge/utils";

export default function CalendarEventsPage({
events,
}: {
Expand Down Expand Up @@ -93,7 +94,7 @@ export default function CalendarEventsPage({
>
<div className="flex justify-between">
<span>
{formatDateRange(item.start_datetime, item.end_datetime)}
{time.formatDateRange(item.start_datetime, item.end_datetime)}
</span>
<span>{item.name}</span>
</div>
Expand All @@ -102,6 +103,7 @@ export default function CalendarEventsPage({
</List>
);
};

const handleSelect = (date: Date) => {
setSelectedDate(date);
};
Expand Down
18 changes: 0 additions & 18 deletions apps/club/src/lib/utils.ts

This file was deleted.

5 changes: 0 additions & 5 deletions apps/cron/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,4 @@ export default [
},
...baseConfig,
...restrictEnvAccess,
{
rules: {
"no-console": "off",
},
},
];
1 change: 1 addition & 0 deletions apps/cron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@forge/api": "workspace:*",
"@forge/consts": "workspace:*",
"@forge/db": "workspace:*",
"@forge/utils": "workspace:*",
"@forge/validators": "workspace:*",
"@t3-oss/env-core": "^0.11.1",
"discord.js": "^14.16.3",
Expand Down
4 changes: 3 additions & 1 deletion apps/cron/src/crons/_example.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { logger } from "@forge/utils";

import { CronBuilder } from "../structs/CronBuilder";

export const testCron = new CronBuilder({
Expand All @@ -6,6 +8,6 @@ export const testCron = new CronBuilder({
}).addCron(
"* * * * * ", // every minute
() => {
console.log("This is an example cron that runs every minute");
logger.log("This is an example cron that runs every minute");
},
);
19 changes: 8 additions & 11 deletions apps/cron/src/crons/alumni-assign.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { and, gt, isNotNull, isNull, lte, or } from "drizzle-orm";

import {
addRoleToMember,
removeRoleFromMember,
resolveDiscordUserId,
} from "@forge/api/utils";
import { DISCORD } from "@forge/consts";
import { db } from "@forge/db/client";
import { Member } from "@forge/db/schemas/knight-hacks";
import { discord, logger } from "@forge/utils";

import { CronBuilder } from "../structs/CronBuilder";

Expand All @@ -27,10 +23,11 @@ export const alumniAssign = new CronBuilder({

for (const { discordUser } of graduatedMembers) {
try {
const discordId = await resolveDiscordUserId(discordUser);
if (discordId) await addRoleToMember(discordId, DISCORD.ALUMNI_ROLE);
const discordId = await discord.resolveDiscordUserId(discordUser);
if (discordId)
await discord.addRoleToMember(discordId, DISCORD.ALUMNI_ROLE);
} catch (err) {
console.error(`Failed to add alumni role for ${discordUser}:`, err);
logger.error(`Failed to add alumni role for ${discordUser}:`, err);
}
}

Expand All @@ -49,11 +46,11 @@ export const alumniAssign = new CronBuilder({

for (const { discordUser } of nonGraduatedMembers) {
try {
const discordId = await resolveDiscordUserId(discordUser);
const discordId = await discord.resolveDiscordUserId(discordUser);
if (discordId)
await removeRoleFromMember(discordId, DISCORD.ALUMNI_ROLE);
await discord.removeRoleFromMember(discordId, DISCORD.ALUMNI_ROLE);
} catch (err) {
console.error(`Failed to remove alumni role for ${discordUser}:`, err);
logger.error(`Failed to remove alumni role for ${discordUser}:`, err);
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion apps/cron/src/crons/animals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import sharp from "sharp";
import { db } from "@forge/db/client";
import { Permissions } from "@forge/db/schemas/auth";
import { Member } from "@forge/db/schemas/knight-hacks";
import { logger } from "@forge/utils";

import { env } from "../env";
import { CronBuilder } from "../structs/CronBuilder";
Expand Down Expand Up @@ -102,7 +103,7 @@ export const goat = new CronBuilder({
].find((u) => u?.trim());

const name = replaceName(`${goat.firstName} ${goat.lastName}`);
console.log("goat chosen: ", name);
logger.log("goat chosen: ", name);

const embed = await createEmbed(
goat.profilePictureUrl,
Expand Down
4 changes: 3 additions & 1 deletion apps/cron/src/crons/backup-filtered-db.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { spawn } from "child_process";
import { createInterface } from "readline/promises";

import { logger } from "@forge/utils";

import { CronBuilder } from "../structs/CronBuilder";

const COMMAND = "pnpm";
Expand Down Expand Up @@ -36,7 +38,7 @@ export const backupFilteredDb = new CronBuilder({
input: stream,
crlfDelay: Infinity,
})) {
if (line) console[key](line);
if (line) logger[key](line);
}
}),
);
Expand Down
15 changes: 9 additions & 6 deletions apps/cron/src/crons/leetcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { APIThreadChannel } from "discord-api-types/v10";
import { Routes, ThreadAutoArchiveDuration } from "discord-api-types/v10";
import { WebhookClient } from "discord.js";

import { discord } from "@forge/api/utils";
import { discord } from "@forge/utils";

import { env } from "../env";
import { CronBuilder } from "../structs/CronBuilder";
Expand Down Expand Up @@ -90,12 +90,15 @@ export const leetcode = new CronBuilder({
embeds: [problemEmbed],
});

const thread = (await discord.post(Routes.threads(msg.channel_id, msg.id), {
body: {
name: dateString,
auto_archive_duration: ThreadAutoArchiveDuration.OneDay,
const thread = (await discord.api.post(
Routes.threads(msg.channel_id, msg.id),
{
body: {
name: dateString,
auto_archive_duration: ThreadAutoArchiveDuration.OneDay,
},
},
})) as APIThreadChannel;
)) as APIThreadChannel;

await LEETCODE_WEBHOOK.send({
content: "Make sure to wrap your solution with spoiler tags!",
Expand Down
Loading