update dockerfile env logic & deploy database cf worker
This commit is contained in:
@ -10,13 +10,17 @@ const CodeEditor = dynamic(() => import("@/components/editor"), {
|
||||
})
|
||||
|
||||
const getUserData = async (id: string) => {
|
||||
const userRes = await fetch(`http://localhost:8787/api/user?id=${id}`)
|
||||
const userRes = await fetch(
|
||||
`https://database.ishaan1013.workers.dev/api/user?id=${id}`
|
||||
)
|
||||
const userData: User = await userRes.json()
|
||||
return userData
|
||||
}
|
||||
|
||||
const getSandboxData = async (id: string) => {
|
||||
const sandboxRes = await fetch(`http://localhost:8787/api/sandbox?id=${id}`)
|
||||
const sandboxRes = await fetch(
|
||||
`https://database.ishaan1013.workers.dev/api/sandbox?id=${id}`
|
||||
)
|
||||
const sandboxData: Sandbox = await sandboxRes.json()
|
||||
return sandboxData
|
||||
}
|
||||
@ -25,7 +29,7 @@ const getSharedUsers = async (usersToSandboxes: UsersToSandboxes[]) => {
|
||||
const shared = await Promise.all(
|
||||
usersToSandboxes.map(async (user) => {
|
||||
const userRes = await fetch(
|
||||
`http://localhost:8787/api/user?id=${user.userId}`
|
||||
`https://database.ishaan1013.workers.dev/api/user?id=${user.userId}`
|
||||
)
|
||||
const userData: User = await userRes.json()
|
||||
return { id: userData.id, name: userData.name }
|
||||
|
@ -11,11 +11,13 @@ export default async function DashboardPage() {
|
||||
redirect("/")
|
||||
}
|
||||
|
||||
const userRes = await fetch(`http://localhost:8787/api/user?id=${user.id}`)
|
||||
const userRes = await fetch(
|
||||
`https://database.ishaan1013.workers.dev/api/user?id=${user.id}`
|
||||
)
|
||||
const userData = (await userRes.json()) as User
|
||||
|
||||
const sharedRes = await fetch(
|
||||
`http://localhost:8787/api/sandbox/share?id=${user.id}`
|
||||
`https://database.ishaan1013.workers.dev/api/sandbox/share?id=${user.id}`
|
||||
)
|
||||
const shared = (await sharedRes.json()) as {
|
||||
id: string
|
||||
|
@ -13,21 +13,26 @@ export default async function AppAuthLayout({
|
||||
redirect("/")
|
||||
}
|
||||
|
||||
const dbUser = await fetch(`http://localhost:8787/api/user?id=${user.id}`)
|
||||
const dbUser = await fetch(
|
||||
`https://database.ishaan1013.workers.dev/api/user?id=${user.id}`
|
||||
)
|
||||
const dbUserJSON = (await dbUser.json()) as User
|
||||
|
||||
if (!dbUserJSON.id) {
|
||||
const res = await fetch("http://localhost:8787/api/user", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: user.id,
|
||||
name: user.firstName + " " + user.lastName,
|
||||
email: user.emailAddresses[0].emailAddress,
|
||||
}),
|
||||
})
|
||||
const res = await fetch(
|
||||
"https://database.ishaan1013.workers.dev/api/user",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: user.id,
|
||||
name: user.firstName + " " + user.lastName,
|
||||
email: user.emailAddresses[0].emailAddress,
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
console.log(res)
|
||||
} else {
|
||||
|
@ -17,7 +17,9 @@ export async function POST(request: NextRequest) {
|
||||
return new Response("Unauthorized", { status: 401 })
|
||||
}
|
||||
|
||||
const res = await fetch(`http://localhost:8787/api/user?id=${clerkUser.id}`)
|
||||
const res = await fetch(
|
||||
`https://database.ishaan1013.workers.dev/api/user?id=${clerkUser.id}`
|
||||
)
|
||||
const user = (await res.json()) as User
|
||||
|
||||
const colorNames = Object.keys(colors)
|
||||
|
@ -8,13 +8,16 @@ export async function createSandbox(body: {
|
||||
userId: string
|
||||
visibility: string
|
||||
}) {
|
||||
const res = await fetch("http://localhost:8787/api/sandbox", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
const res = await fetch(
|
||||
"https://database.ishaan1013.workers.dev/api/sandbox",
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
)
|
||||
|
||||
return await res.text()
|
||||
}
|
||||
@ -24,7 +27,7 @@ export async function updateSandbox(body: {
|
||||
name?: string
|
||||
visibility?: "public" | "private"
|
||||
}) {
|
||||
await fetch("http://localhost:8787/api/sandbox", {
|
||||
await fetch("https://database.ishaan1013.workers.dev/api/sandbox", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@ -36,7 +39,7 @@ export async function updateSandbox(body: {
|
||||
}
|
||||
|
||||
export async function deleteSandbox(id: string) {
|
||||
await fetch(`http://localhost:8787/api/sandbox?id=${id}`, {
|
||||
await fetch(`https://database.ishaan1013.workers.dev/api/sandbox?id=${id}`, {
|
||||
method: "DELETE",
|
||||
})
|
||||
|
||||
@ -44,13 +47,16 @@ export async function deleteSandbox(id: string) {
|
||||
}
|
||||
|
||||
export async function shareSandbox(sandboxId: string, email: string) {
|
||||
const res = await fetch("http://localhost:8787/api/sandbox/share", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ sandboxId, email }),
|
||||
})
|
||||
const res = await fetch(
|
||||
"https://database.ishaan1013.workers.dev/api/sandbox/share",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ sandboxId, email }),
|
||||
}
|
||||
)
|
||||
const text = await res.text()
|
||||
|
||||
if (res.status !== 200) {
|
||||
@ -62,7 +68,7 @@ export async function shareSandbox(sandboxId: string, email: string) {
|
||||
}
|
||||
|
||||
export async function unshareSandbox(sandboxId: string, userId: string) {
|
||||
await fetch("http://localhost:8787/api/sandbox/share", {
|
||||
await fetch("https://database.ishaan1013.workers.dev/api/sandbox/share", {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
Reference in New Issue
Block a user