Skip to content

Commit

Permalink
fixed build errors to make dockerhub work
Browse files Browse the repository at this point in the history
  • Loading branch information
eibrahim committed Feb 17, 2025
1 parent 79243c0 commit 198ac29
Show file tree
Hide file tree
Showing 34 changed files with 170 additions and 500 deletions.
1 change: 0 additions & 1 deletion .cursor/rules/app-rule.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ generator client {
/src
/lib
/calendar
parser.ts # ICS parsing utilities
sync.ts # Feed synchronization
events.ts # Event management
types.ts # Type definitions
Expand Down
17 changes: 11 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"date-fns": "^3.6.0",
"date-fns-tz": "^3.2.0",
"googleapis": "^144.0.0",
"ical.js": "^2.1.0",
"next": "15.1.6",
"next-auth": "^4.24.11",
"react": "^19.0.0",
Expand All @@ -70,6 +69,7 @@
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.1.6",
"eslint-formatter-compact": "^8.40.0",
"postcss": "^8",
"prisma": "^6.3.1",
"tailwindcss": "^3.4.1",
Expand Down
8 changes: 3 additions & 5 deletions src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NextAuth, { AuthOptions } from "next-auth";
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google";

declare module "next-auth" {
Expand All @@ -23,7 +23,7 @@ declare module "next-auth/jwt" {
}
}

export const authOptions: AuthOptions = {
const handler = NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
Expand Down Expand Up @@ -82,8 +82,6 @@ export const authOptions: AuthOptions = {
strategy: "jwt",
maxAge: 30 * 24 * 60 * 60, // 30 days
},
};

const handler = NextAuth(authOptions);
});

export { handler as GET, handler as POST };
12 changes: 6 additions & 6 deletions src/app/api/calendar/google/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ interface UpdateRequest {
// Update a Google Calendar feed
export async function PATCH(
request: Request,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const feed = await prisma.calendarFeed.findUnique({
where: { id: id },
where: { id },
include: { account: true },
});

Expand All @@ -30,7 +30,7 @@ export async function PATCH(

// Update only local properties
const updatedFeed = await prisma.calendarFeed.update({
where: { id: id },
where: { id },
data: {
enabled: updates.enabled,
color: updates.color,
Expand All @@ -56,12 +56,12 @@ export async function PATCH(
// Delete a Google Calendar feed
export async function DELETE(
request: Request,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const feed = await prisma.calendarFeed.findUnique({
where: { id: id },
where: { id },
include: { account: true },
});

Expand All @@ -74,7 +74,7 @@ export async function DELETE(

// Delete the feed and all its events
await prisma.calendarFeed.delete({
where: { id: id },
where: { id },
});

return NextResponse.json({ success: true });
Expand Down
21 changes: 12 additions & 9 deletions src/app/api/events/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";

interface RouteParams {
params: {
id: string;
};
}

// Get a specific event
export async function GET(request: Request, { params }: RouteParams) {
export async function GET(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const event = await prisma.calendarEvent.findUnique({
Expand All @@ -30,7 +27,10 @@ export async function GET(request: Request, { params }: RouteParams) {
}

// Update a specific event
export async function PATCH(request: Request, { params }: RouteParams) {
export async function PATCH(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const updates = await request.json();
Expand All @@ -49,7 +49,10 @@ export async function PATCH(request: Request, { params }: RouteParams) {
}

// Delete a specific event
export async function DELETE(request: Request, { params }: RouteParams) {
export async function DELETE(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
await prisma.calendarEvent.delete({
Expand Down
30 changes: 18 additions & 12 deletions src/app/api/feeds/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";

interface RouteParams {
params: {
id: string;
};
}

// Get a specific feed
export async function GET(request: Request, { params }: RouteParams) {
export async function GET(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const feed = await prisma.calendarFeed.findUnique({
where: { id: params.id },
where: { id },
include: { events: true },
});

Expand All @@ -30,11 +28,15 @@ export async function GET(request: Request, { params }: RouteParams) {
}

// Update a specific feed
export async function PATCH(request: Request, { params }: RouteParams) {
export async function PATCH(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const updates = await request.json();
const updated = await prisma.calendarFeed.update({
where: { id: params.id },
where: { id },
data: updates,
});
return NextResponse.json(updated);
Expand All @@ -48,11 +50,15 @@ export async function PATCH(request: Request, { params }: RouteParams) {
}

// Delete a specific feed
export async function DELETE(request: Request, { params }: RouteParams) {
export async function DELETE(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
// The feed's events will be automatically deleted due to the cascade delete in the schema
await prisma.calendarFeed.delete({
where: { id: params.id },
where: { id },
});
return NextResponse.json({ success: true });
} catch (error) {
Expand Down
26 changes: 14 additions & 12 deletions src/app/api/feeds/[id]/sync/route.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";

interface RouteParams {
params: {
id: string;
};
interface CalendarEventInput {
start: string | Date;
end: string | Date;
created?: string | Date;
lastModified?: string | Date;
[key: string]: unknown;
}

export async function POST(request: Request, { params }: RouteParams) {
export async function POST(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { events } = await request.json();
const feedId = params.id;
const { id: feedId } = await params;

// Start a transaction to ensure data consistency
await prisma.$transaction(async (tx) => {
Expand All @@ -22,7 +27,7 @@ export async function POST(request: Request, { params }: RouteParams) {
// Insert new events
if (events && events.length > 0) {
await tx.calendarEvent.createMany({
data: events.map((event: any) => ({
data: events.map((event: CalendarEventInput) => ({
...event,
feedId,
// Convert Date objects to strings for database storage
Expand All @@ -47,10 +52,7 @@ export async function POST(request: Request, { params }: RouteParams) {

return NextResponse.json({ success: true });
} catch (error) {
console.error("Failed to sync feed events:", error);
return NextResponse.json(
{ error: "Failed to sync feed events" },
{ status: 500 }
);
console.error("Failed to sync feed:", error);
return NextResponse.json({ error: "Failed to sync feed" }, { status: 500 });
}
}
8 changes: 7 additions & 1 deletion src/app/api/feeds/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";

interface CalendarFeedUpdate {
id: string;
enabled?: boolean;
color?: string | null;
}

// List all calendar feeds
export async function GET() {
try {
Expand Down Expand Up @@ -53,7 +59,7 @@ export async function PUT(request: Request) {

// Use transaction to ensure all updates succeed or none do
await prisma.$transaction(
feeds.map((feed: any) =>
feeds.map((feed: CalendarFeedUpdate) =>
prisma.calendarFeed.update({
where: { id: feed.id },
data: feed,
Expand Down
13 changes: 6 additions & 7 deletions src/app/api/projects/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
import { ProjectStatus } from "@/types/project";

export async function GET(
request: Request,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = params;
const { id } = await params;
const project = await prisma.project.findUnique({
where: { id },
include: {
Expand All @@ -31,10 +30,10 @@ export async function GET(

export async function PUT(
request: Request,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = params;
const { id } = await params;
const json = await request.json();

const project = await prisma.project.update({
Expand All @@ -61,10 +60,10 @@ export async function PUT(

export async function DELETE(
request: Request,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = params;
const { id } = await params;

// First, remove project reference from all tasks
await prisma.task.updateMany({
Expand Down
Loading

0 comments on commit 198ac29

Please sign in to comment.