This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
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.
- Loading branch information
Showing
11 changed files
with
143 additions
and
149 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { AuthOptions } from "next-auth" | ||
import GoogleProvider from "next-auth/providers/google"; | ||
import GithubProvider from "next-auth/providers/github" | ||
import { TypeORMAdapter } from "@auth/typeorm-adapter" | ||
import { Adapter } from "next-auth/adapters"; | ||
import dataSourceOptions from "@/app/api/db/options"; | ||
|
||
const authOptions: AuthOptions = { | ||
adapter: TypeORMAdapter(dataSourceOptions) as Adapter, | ||
providers: [ | ||
GithubProvider({ | ||
clientId: process.env.GITHUB_ID as string, | ||
clientSecret: process.env.GITHUB_SECRET as string, | ||
}), | ||
GoogleProvider({ | ||
clientId: process.env.GOOGLE_CLIENT_ID as string, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, | ||
}), | ||
], | ||
} | ||
|
||
|
||
export default authOptions; |
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,18 @@ | ||
import { DataSourceOptions } from "typeorm" | ||
|
||
const env = process.env.NODE_ENV; | ||
const dataSourceOptions: DataSourceOptions = { | ||
type: "postgres", | ||
host: (process.env.POSTGRES_HOST || "localhost") as string, | ||
port: Number(process.env.POSTGRES_PORT || 5432), | ||
username: process.env.POSTGRES_USER as string, | ||
password: process.env.POSTGRES_PASSWORD as string, | ||
database: (process.env.POSTGRES_DATABASE || "falkordb") as string, | ||
synchronize: (env == "development" ? true : false), | ||
ssl: (env == "development" ? undefined : { | ||
rejectUnauthorized: false, | ||
requestCert: true, | ||
}), | ||
} | ||
|
||
export default dataSourceOptions; |
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,38 @@ | ||
'use client'; | ||
|
||
import { useSession, getSession, signIn } from "next-auth/react" | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default function Page() { | ||
const { data: session, status } = useSession() | ||
|
||
if (status === "loading") { | ||
return <p className="text-blue-600 text-3xl">Loading...</p> | ||
} | ||
|
||
if (status === "unauthenticated") { | ||
signIn(undefined, { callbackUrl: '/sandbox' }) | ||
} | ||
|
||
function createSandbox(){ | ||
fetch('/api/db', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({session: session}) | ||
}) | ||
.then(response => { | ||
console.log(response.json()) | ||
redirect('/dashboard') | ||
}) | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col items-center justify-center min-h-screen py-2"> | ||
<main className="flex flex-col items-center justify-center flex-1 px-20 text-center"> | ||
<button className="rounded-full bg-blue-600 text-6xl font-bold p-5" onClick={createSandbox}>Create Sandbox</button> | ||
</main> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.