-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new pricing table with free trial
also record refcode in the plan gate, too
- Loading branch information
Showing
6 changed files
with
134 additions
and
40 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,16 @@ | ||
import { getRequestContext } from "@cloudflare/next-on-pages" | ||
|
||
export const runtime = "edge" | ||
|
||
export async function GET ( | ||
request: Request, | ||
{ params: { email } }: { params: { email: string } } | ||
) { | ||
const result = await getRequestContext().env.REFERRALS. | ||
prepare(`SELECT refcode FROM referrals WHERE email = ?`). | ||
bind(email). | ||
first() | ||
return Response.json({ | ||
refcode: result?.refcode | ||
}) | ||
} |
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,24 @@ | ||
import { getRequestContext } from "@cloudflare/next-on-pages" | ||
import { generateRefcode } from "@/lib/referrals" | ||
|
||
export const runtime = "edge" | ||
|
||
export async function POST(request: Request){ | ||
const form = await request.formData() | ||
const email = form.get('email') | ||
const refcode = generateRefcode() | ||
const referralsDB = getRequestContext().env.REFERRALS | ||
const insertStmt = referralsDB.prepare(` | ||
INSERT INTO users (email, refcode) | ||
VALUES (?, ?) | ||
`).bind(email, refcode) | ||
const result = await insertStmt.run() | ||
if (result.error) { | ||
return { | ||
errors: [result.error] | ||
} | ||
} | ||
return Response.json({ | ||
refcode | ||
}) | ||
} |
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