-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some security updates and new features
- Loading branch information
1 parent
b150a37
commit 0d58d51
Showing
22 changed files
with
256 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function GET(request) { | ||
try { | ||
const res = NextResponse.json( | ||
{ | ||
message: "Logged out successfully", | ||
}, | ||
{ | ||
status: 200, | ||
} | ||
); | ||
res.cookies.set("authToken", "", { | ||
httpOnly: true, | ||
secure: true, | ||
sameSite: "strict", | ||
path: "/", | ||
expires: new Date(0), | ||
}); | ||
return res; | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ | ||
error: error.message, | ||
}, | ||
{ | ||
status: 500, | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import CompilerEditor from "@/components/Editor/Compiler"; | ||
|
||
const getData = async (id) => { | ||
try { | ||
if (!process.env.BASE_URL) { | ||
throw new Error("BASE_URL is not defined in environment variables"); | ||
} | ||
const req = await fetch(`${process.env.BASE_URL}/api/projects/${id}`, { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
credentials: "include", | ||
}); | ||
if (!req.ok) { | ||
const errorText = (await req.json()) || { error: "Failed to fetch data" }; | ||
throw new Error(`Error ${req.status}: ${errorText?.error}`); | ||
} | ||
const res = await req.json(); | ||
return res; | ||
} catch (error) { | ||
return { | ||
error: error.message, | ||
}; | ||
} | ||
}; | ||
|
||
export async function generateMetadata({ params }) { | ||
const { slug } = params; | ||
return { | ||
title: `Codeframer | online ${slug[0]} compiler`, | ||
description: `codeframer provides online ${slug[0]} compiler to compile and run your code online`, | ||
}; | ||
} | ||
|
||
const Compiler = async ({ params }) => { | ||
const { slug } = params; | ||
fetch(`${process.env.COMPILER_URL}/status`); | ||
if (slug[0] !== "python") { | ||
return ( | ||
<main className="flex h-screen w-full items-center justify-center text-3xl font-light"> | ||
Language not supported | ||
</main> | ||
); | ||
} | ||
if (slug[1]) { | ||
const data = await getData(slug[1]); | ||
if (data.error) | ||
return ( | ||
<main className="flex h-screen w-full items-center justify-center text-3xl font-light"> | ||
{data?.error} | ||
</main> | ||
); | ||
return <CompilerEditor language={slug[0]} data={data} />; | ||
} | ||
return <CompilerEditor language={slug[0]} />; | ||
}; | ||
|
||
export default Compiler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.