Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
Co-Authored-By: Bloxs <[email protected]>
  • Loading branch information
quick007 and Blocksnmore committed Jan 17, 2024
1 parent fe7b079 commit 1494754
Show file tree
Hide file tree
Showing 15 changed files with 4,728 additions and 202 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ IMAGEKIT_PUBLIC_KEY=<imagekit public key> (i.e. "public_...")
IMAGEKIT_PRIVATE_KEY=<imagekit private key> (i.e. "private_...")
IMAGEKIT_URL_ENDPOINT=<imagekit url> (i.e. "https://ik.imagekit.io/...")
AWS_ACCESS_KEY_ID=....
AWS_SECRET_ACCESS_KEY=....
AWS_SECRET_ACCESS_KEY=....
AWS_EMAIL_SOURCE="Name <[email protected]>"
14 changes: 13 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ jobs:
with:
deno-version: v1.x

- name: Build step
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: "18"
cache: "yarn"

- name: Install node depends
run: yarn install

- name: Build Emails
run: yarn run export

- name: Build Fresh Website
env:
ALLOWED_EMAILS: ${{ secrets.ALLOWED_EMAILS }}
IMAGEKIT_ENABLED: ${{ secrets.IMAGEKIT_ENABLED }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@

# Fresh build directory
/_fresh
/db
/db
/.react-email
/out
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"deno.lint": true,
"deno.unstable": true,
"deno.cacheOnSave": true,
"deno.config": "deno.jsonc",
"emmet.includeLanguages": {
"javascriptreact": "html",
"typescriptreact": "html"
}
},
"deno.disablePaths": ["./.react-email"]
}
7 changes: 4 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"lock": false,
"nodeModulesDir": true,
"tasks": {
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"fmt": "npx prettier . --write",
Expand All @@ -11,7 +10,7 @@
},
"lint": { "rules": { "tags": ["fresh", "recommended"] } },
"imports": {
"$fresh/": "https://deno.land/x/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"preact-render-to-string": "https://esm.sh/*[email protected]",
Expand All @@ -26,7 +25,9 @@
"tailwindcss": "npm:[email protected]",
"tailwindcss/": "npm:/[email protected]/",
"tailwindcss/plugin": "npm:/[email protected]/plugin.js",
"@tailwindcss/typography": "npm:@tailwindcss/typography"
"@tailwindcss/typography": "npm:@tailwindcss/typography",
"react": "npm:react",
"@react-email/components": "npm:@react-email/components"
},
"compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" },
"exclude": ["**/_fresh/*"]
Expand Down
52 changes: 52 additions & 0 deletions emails/login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {
Body,
Container,
Head,
Heading,
Html,
Img,
Link,
Section,
Tailwind,
Text,
} from "@react-email/components";
import * as React from "react";
import config from "../tailwind.config.ts"

export default function LoginEmail({ otp = "123456" }: { otp: string }) {
return (
<Html>
<Head />
<Tailwind config={{
theme: config.theme
}}>
<Body className="bg-white">
<Container className="">
<Img
src={`https://events.deno.dev/orange-logo.svg`}
width="212"
height="88"
alt="Plaid"
/>
<Text >Verify Your Identity</Text>
<Heading >
Enter the following code to finish linking Venmo.
</Heading>
<Section>
<Text>{otp}</Text>
</Section>
<Text>Not expecting this email?</Text>
<Text>
Contact{" "}
<Link href="mailto:[email protected]">
[email protected]
</Link>{" "}
if you did not request this code.
</Text>
</Container>
</Body>
</Tailwind>
</Html>
);
}

2 changes: 1 addition & 1 deletion fresh.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from "$fresh/server.ts";
import tailwind from "./plugins/tailwind.ts";
import tailwind from "$fresh/plugins/tailwind.ts";
import { kvInsightsPlugin } from "https://deno.land/x/[email protected]/mod.ts";
import { kv } from "@/utils/db/kv.ts";

Expand Down
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "emails",
"version": "0.0.18",
"private": true,

"workspaces": [
".react-email"
],
"scripts": {
"dev": "email dev",
"export": "email export"
},
"dependencies": {
"@react-email/components": "^0.0.12",
"react-email": "1.10.0"
}
}
112 changes: 0 additions & 112 deletions plugins/tailwind.ts

This file was deleted.

75 changes: 0 additions & 75 deletions plugins/tailwind/compiler.ts

This file was deleted.

9 changes: 7 additions & 2 deletions routes/api/auth/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
import { deleteCookie, setCookie } from "$std/http/cookie.ts";
import { sendEmail } from "@/utils/email/client.ts";

const emailHTML = await Deno.readTextFile("./out/login.html");

const emailRegex =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

Expand Down Expand Up @@ -45,10 +47,13 @@ export const handler: Handlers<{ email: string; otp: string }> = {
}

const otp = await generateOTP(email);

const otpHTML = emailHTML.replace("123456", otp);

try {
await sendEmail([email], "Your Events Authorization Code", {
content: `Your one time login code is ${otp}.<br/> <b>Do not share it with anyone</b>`,
html: true,
html: otpHTML,
fallback: `Your one time login code is ${otp}. Do not share it with anyone.`,
});
} catch (err) {
console.error(err);
Expand Down
Binary file added static/orange-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1494754

Please sign in to comment.