Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ yarn-error.log*
.env*.local
.env.production
.env.development
.env
.env.example


# vercel
.vercel
Expand Down
4 changes: 2 additions & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# #!/usr/bin/env sh
# . "$(dirname -- "$0")/_/husky.sh"

# Validate commit message format
npx --no -- commitlint --edit "$1"
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.18.0
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.18.0
32 changes: 17 additions & 15 deletions app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { Account } from "next-auth";
import { type NextRequest } from 'next/server';
import { Auth, type AuthConfig } from '@auth/core';
import Google from '@auth/core/providers/google';

interface GoogleProfile {
email?: string;
email_verified?: boolean;
name?: string;
picture?: string;
}
export const runtime = 'edge';

const handler = NextAuth({
const config: AuthConfig = {
providers: [
GoogleProvider({
Google({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
],
callbacks: {
async signIn({ account, profile }: { account: Account | null; profile?: GoogleProfile }) {
async signIn({ account, profile }) {
if (account?.provider === "google" && profile?.email) {
return profile.email.endsWith('.vjti.ac.in');
}
return false;
},
async redirect({ url, baseUrl }: { url: string; baseUrl: string }) {
async redirect({ url, baseUrl }) {
if (url.startsWith(baseUrl)) return url;
else if (url.startsWith("/")) return new URL(url, baseUrl).toString();
return baseUrl + "/dashboard";
Expand All @@ -33,6 +28,13 @@ const handler = NextAuth({
signIn: "/auth/signin",
error: "/auth/error",
},
});
secret: process.env.NEXTAUTH_SECRET,
};

export async function GET(request: NextRequest) {
return await Auth(request, config);
}

export { handler as GET, handler as POST };
export async function POST(request: NextRequest) {
return await Auth(request, config);
}
31 changes: 17 additions & 14 deletions app/api/resources/[domain]/route.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import { NextResponse } from 'next/server';
import path from 'path';
import fs from 'fs/promises';
import { NextRequest } from 'next/server';

export const runtime = 'edge';

const resources = {
"cp": [],
"dev": [],
"eth": [],
"ai": [],
"proj-x": []
};

export async function GET(
request: Request,
request: NextRequest,
{ params }: { params: { domain: string } }
) {
try {
const domain = params.domain;
const jsonDirectory = path.join(process.cwd(), 'data', 'resources');
const fileContents = await fs.readFile(
jsonDirectory + `/${domain}.json`,
'utf8'
);
const data = JSON.parse(fileContents);
const domainResources = resources[domain as keyof typeof resources] || [];

return NextResponse.json(data);
} catch (error) {
console.error(`Error loading ${params.domain} resources:`, error);
return NextResponse.json(domainResources);
} catch {
return NextResponse.json(
{ error: `Failed to load ${params.domain} resources` },
{ error: "Failed to load domain resources" },
{ status: 500 }
);
}
}
}
25 changes: 14 additions & 11 deletions app/api/resources/route.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { NextResponse } from 'next/server';
import path from 'path';
import fs from 'fs/promises';

export const runtime = 'edge';

const resources = {
"cp": [],
"dev": [],
"eth": [],
"ai": [],
"proj-x": []
};

export async function GET() {
try {
const jsonDirectory = path.join(process.cwd(), 'resources');
const fileContents = await fs.readFile(jsonDirectory + '/resources.json', 'utf8');
const data = JSON.parse(fileContents);

return NextResponse.json(data);
} catch (error) {
console.error('Error loading resources:', error);
return NextResponse.json(resources);
} catch {
return NextResponse.json(
{ error: 'Failed to load resources' },
{ error: "Failed to load resources" },
{ status: 500 }
);
}
}
}
2 changes: 2 additions & 0 deletions app/dashboard/[domain]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ interface Domain {
categories: string[];
}

export const runtime = 'edge';

export default function DomainPage() {
// const { data: session } = useSession();
const params = useParams();
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"@eslint/eslintrc": "^3.2.0",
"@types/eventsource": "^1.1.15",
"@types/node": "^20.17.10",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@types/three": "^0.171.0",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"act": "^0.0.6",
Expand All @@ -75,5 +77,8 @@
"eslint --fix",
"prettier --write"
]
},
"engines": {
"node": ">=18.18.0"
}
}
Loading
Loading