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 claim-db-worker/public/copy-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added claim-db-worker/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions claim-db-worker/public/magic-wand-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added claim-db-worker/public/og-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 11 additions & 9 deletions claim-db-worker/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getClaimSuccessHtml } from './templates/claim-success-template';
import { getClaimHtml } from './templates/claim-template';
import { getErrorHtml } from './templates/error-template';
import { getHomepageHtml } from './templates/homepage-template';

interface Env {
CLAIM_DB_RATE_LIMITER: RateLimit;
Expand Down Expand Up @@ -36,11 +37,11 @@ export default {
const url = new URL(request.url);

// Add a test route for local development to preview the success page
if (url.pathname === '/test-success') {
return new Response(getClaimSuccessHtml('cmddkid4303fly70vbmzqekl9'), {
headers: { 'Content-Type': 'text/html' },
});
}
// if (url.pathname === '/test-success') {
// return new Response(getClaimSuccessHtml('cmddkid4303fly70vbmzqekl9'), {
// headers: { 'Content-Type': 'text/html' },
// });
// }

// --- OAuth Callback Handler ---
if (url.pathname === '/auth/callback') {
Expand Down Expand Up @@ -81,8 +82,6 @@ export default {

const tokenData = (await tokenResponse.json()) as { access_token: string };

console.log('tokenData: ', JSON.stringify(tokenData, null, 2));

// Transfer project
const transferResponse = await fetch(`https://api.prisma.io/v1/projects/${projectID}/transfer`, {
method: 'POST',
Expand All @@ -98,7 +97,6 @@ export default {
blobs: ['database_claimed'],
indexes: ['claim_db'],
});

return new Response(getClaimSuccessHtml(projectID), {
headers: { 'Content-Type': 'text/html' },
});
Expand All @@ -115,7 +113,7 @@ export default {

// --- Main Claim Page Handler ---
const projectID = url.searchParams.get('projectID');
if (projectID) {
if (projectID && projectID !== 'undefined') {
const redirectUri = new URL('/auth/callback', request.url);
redirectUri.searchParams.set('projectID', projectID);

Expand All @@ -130,6 +128,10 @@ export default {
return new Response(getClaimHtml(projectID, authUrl), {
headers: { 'Content-Type': 'text/html' },
});
} else if (url.pathname === '/' && projectID !== 'undefined') {
return new Response(getHomepageHtml(), {
headers: { 'Content-Type': 'text/html' },
});
}

// --- Fallback: No project ID provided ---
Expand Down
9 changes: 5 additions & 4 deletions claim-db-worker/src/templates/claim-success-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ export function getClaimSuccessHtml(projectID: string) {
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/png" href="/favicon.png"/>
<title>Congratulations!</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;700&display=swap');
body {
margin: 0;
padding: 0;
min-height: 100vh;
background: url('/hero-background.svg') no-repeat center center fixed;
background-size: cover;
color: #fff;
font-family: 'Inter', system-ui, sans-serif;
font-family: 'Barlow', system-ui, sans-serif;
display: flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -109,8 +110,8 @@ export function getClaimSuccessHtml(projectID: string) {
</head>
<body>
<div class="container">
<div class="logo">
<img src="/prisma-postgres-logo.svg" alt="Prisma Postgres Logo" class="logo-icon">
<div>
<img src="/prisma-postgres-logo.svg" alt="Prisma Postgres Logo" width="250" height="100">
</div>
<div class="title">Congratulations!</div>
<div class="message">You have successfully claimed your database</div>
Expand Down
5 changes: 3 additions & 2 deletions claim-db-worker/src/templates/claim-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ export function getClaimHtml(projectID: string, authUrl: string) {
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/png" href="/favicon.png"/>
<title>Claim Project</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;700&display=swap');
body {
font-family: 'Inter', system-ui, sans-serif;
font-family: 'Barlow', system-ui, sans-serif;
background: url('/hero-background.svg') no-repeat center center fixed;
background-size: cover;
margin: 0;
Expand Down
4 changes: 3 additions & 1 deletion claim-db-worker/src/templates/error-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ export function getErrorHtml(title: string, message: string, details?: string) {
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="shortcut icon" type="image/png" href="/favicon.png"/>
<title>${title}</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;700&display=swap');
body {
margin: 0;
padding: 0;
min-height: 100vh;
background: url('/hero-background.svg') no-repeat center center fixed;
background-size: cover;
color: #fff;
font-family: 'Inter', system-ui, sans-serif;
font-family: 'Barlow', system-ui, sans-serif;
display: flex;
align-items: center;
justify-content: center;
Expand Down
Loading