Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
679 changes: 376 additions & 303 deletions Backend/v1/package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions Backend/v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@prisma/client": "^6.9.0",
"@prisma/client": "^6.12.0",
"@prisma/extension-accelerate": "^2.0.1",
"argon2": "^0.43.1",
"express": "^5.1.0",
"hono": "^4.7.7"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250214.0",
"@types/argon2": "^0.14.1",
"@types/node": "^22.15.30",
"prisma": "^6.9.0",
"wrangler": "^4.4.0"
"prisma": "^6.12.0",
"wrangler": "^4.25.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:

- You are about to drop the `PageViews` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropTable
DROP TABLE "PageViews";
16 changes: 16 additions & 0 deletions Backend/v1/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,20 @@ model Visitor {
staffId String?
user User? @relation("UserVisits", fields: [userId], references: [uniqueId])
staff Staff? @relation("StaffVisits", fields: [staffId], references: [staffId])
}

model BoardMember {
id Int @id @default(autoincrement())
name String
image String
title String
tagline String
post String
}

model CarouselImage {
id Int @id @default(autoincrement())
image String
title String
tagline String
}
6 changes: 6 additions & 0 deletions Backend/v1/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Hono } from "hono";
import { PrismaClient } from '@prisma/client/edge';
import { withAccelerate } from '@prisma/extension-accelerate';
import { cors } from 'hono/cors';
import userRouter from "./routes/userRouter";

const app = new Hono();

Expand All @@ -26,6 +27,11 @@ app.get("/", (c) => {
);
});

// In your main app file (index.ts or similar)
app.route('/user', userRouter);
app.route('/about', aboutRouter);


// Initialize Prisma client
const prisma = new PrismaClient({
datasourceUrl: process.env.DIRECT_URL
Expand Down
73 changes: 73 additions & 0 deletions Backend/v1/src/routes/about.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Hono } from 'hono';
import { PrismaClient } from '@prisma/client/edge';
import { withAccelerate } from '@prisma/extension-accelerate';
import { cors } from 'hono/cors';

const aboutRouter = new Hono();

// Initialize Prisma client
const prisma = new PrismaClient({
datasourceUrl: process.env.DIRECT_URL
}).$extends(withAccelerate());

aboutRouter.use('/*', cors({
origin: ['http://localhost:5173', 'https://codeclubagpit.vercel.app'],
allowMethods: ['GET', 'OPTIONS'],
allowHeaders: ['Content-Type'],
exposeHeaders: ['Content-Length'],
maxAge: 600,
credentials: true,
}));

aboutRouter.options('*', (c) => {
return new Response(null, { status: 204 });
});


aboutRouter.get('/board-members', async (c) => {
try {
const boardMembers = await prisma.boardMember.findMany({
select: {
id: true,
name: true,
image: true,
title: true,
tagline: true,
post: true,
},
});

return c.json({ success: true, boardMembers });
} catch (error) {
console.error('Board members fetch error:', error);
return c.json({
success: false,
message: 'Internal server error',
details: error instanceof Error ? error.message : 'Unknown error'
}, 500);
}
});

aboutRouter.get('/carousel-images', async (c) => {
try {
const images = await prisma.carouselImage.findMany({
select: {
id: true,
image: true,
title: true,
tagline: true,
},
});

return c.json({ success: true, images });
} catch (error) {
console.error('Carousel images fetch error:', error);
return c.json({
success: false,
message: 'Internal server error',
details: error instanceof Error ? error.message : 'Unknown error'
}, 500);
}
});

export default aboutRouter;
56 changes: 56 additions & 0 deletions Backend/v1/src/routes/eventRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Hono } from 'hono';
import { PrismaClient } from '@prisma/client/edge';
import { withAccelerate } from '@prisma/extension-accelerate';
import { cors } from 'hono/cors';

// Define the events router
const eventsRouter = new Hono();

// Initialize Prisma client
const prisma = new PrismaClient({
datasourceUrl: process.env.DIRECT_URL
}).$extends(withAccelerate());

// Apply CORS middleware for events routes
eventsRouter.use('/*', cors({
origin: ['http://localhost:5173', 'https://codeclubagpit.vercel.app'],
allowMethods: ['GET', 'OPTIONS'],
allowHeaders: ['Content-Type'],
exposeHeaders: ['Content-Length'],
maxAge: 600,
credentials: true,
}));

// Handle preflight requests
eventsRouter.options('*', (c) => {
return new Response(null, { status: 204 });
});

// Events route
eventsRouter.get('/events', async (c) => {
try {
const events = await prisma.event.findMany({
select: {
name1: true,
year: true,
detail: true,
description: true,
image1: true,
image2: true,
image3: true,
status: true,
},
});

return c.json({ success: true, events });
} catch (error) {
console.error('Events fetch error:', error);
return c.json({
success: false,
message: 'Internal server error',
details: error instanceof Error ? error.message : 'Unknown error'
}, 500);
}
});

export default eventsRouter;
Loading