diff --git a/README.md b/README.md index dfd02e3..c58c20d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Events -Events is a simple and easy to use event ticketing system. View the production website on https://events.deno.dev/! +Events is a simple and easy to use event ticketing system. View the production +website on https://events.deno.dev/! ## Contributing @@ -8,5 +9,8 @@ Contribution guide coming soon! ## Hosting -Events is built with [Deno Deploy](https://deno.com/deploy) support in mind but you should be able to selfhost this anywhere, just copy `.env.example` to `.env` and update the variables. -If you're selfhosting then KV requires an extra step with either creating a `db` folder for the database to be stored in or setting `DENO_DEPLOYMENT_ID` to anything for it to use the global version. +Events is built with [Deno Deploy](https://deno.com/deploy) support in mind but +you should be able to selfhost this anywhere, just copy `.env.example` to `.env` +and update the variables. If you're selfhosting then KV requires an extra step +with either creating a `db` folder for the database to be stored in or setting +`DENO_DEPLOYMENT_ID` to anything for it to use the global version. diff --git a/components/buttons/toggle.tsx b/components/buttons/toggle.tsx index 7b1141d..ccb7013 100644 --- a/components/buttons/toggle.tsx +++ b/components/buttons/toggle.tsx @@ -1,4 +1,3 @@ - // basic switch if we ever need to use it export const Switch = ({ enabled, diff --git a/components/hooks/fakeFormik/index.tsx b/components/hooks/fakeFormik/index.tsx index db68a2b..98b4ecf 100644 --- a/components/hooks/fakeFormik/index.tsx +++ b/components/hooks/fakeFormik/index.tsx @@ -3,16 +3,6 @@ import { useState } from "preact/hooks"; import { ComponentChild, JSX } from "preact"; import * as Yup from "yup"; -type Json = - | null - | string - | number - | boolean - | Array - | { - [prop: string]: Json; - }; - interface FormProps extends JSX.HTMLAttributes { children: ComponentChild; } diff --git a/components/layout/navbar.tsx b/components/layout/navbar.tsx index 15e1871..32d13fb 100644 --- a/components/layout/navbar.tsx +++ b/components/layout/navbar.tsx @@ -1,7 +1,7 @@ -import { UserPartial } from "@/utils/db/kv.ts"; +import { User } from "@/utils/db/kv.ts"; import NavbarDropDown from "../../islands/components/pieces/navDropDown.tsx"; -const Navbar = ({ user }: { user: UserPartial | undefined }) => { +const Navbar = ({ user }: { user: User | undefined }) => { const loggedIn = true; return ( diff --git a/deno.jsonc b/deno.jsonc index 188e5e9..5a259c5 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -2,13 +2,16 @@ "lock": false, "tasks": { "check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx", - "fmt": "npx prettier . --write", + // Do items like reordering imports + "fmt": "deno fmt && npx prettier . --write", "start": "deno run -A --unstable --watch=static/,routes/ dev.ts", "build": "deno run -A --unstable dev.ts build", "preview": "deno run --unstable -A main.ts", "update": "deno run --unstable -A -r https://fresh.deno.dev/update ." }, - "lint": { "rules": { "tags": ["fresh", "recommended"] } }, + "lint": { + "rules": { "tags": ["fresh", "recommended"], "include": ["no-unused-vars"] } + }, "imports": { "$fresh/": "https://deno.land/x/fresh@1.6.3/", "preact": "https://esm.sh/preact@10.19.2", diff --git a/emails/login.tsx b/emails/login.tsx index 5d7162d..2c5775e 100644 --- a/emails/login.tsx +++ b/emails/login.tsx @@ -1,18 +1,18 @@ import { Body, + Column, Container, + Font, Head, Heading, Html, Img, Link, + Preview, + Row, Section, Tailwind, Text, - Preview, - Font, - Column, - Row, } from "@react-email/components"; import * as React from "react"; import config from "../tailwind.config.ts"; diff --git a/fresh.gen.ts b/fresh.gen.ts index f3a1569..fadfb2b 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -11,6 +11,7 @@ import * as $_404 from "./routes/_404.tsx"; import * as $_app from "./routes/_app.tsx"; import * as $_layout from "./routes/_layout.tsx"; import * as $api_auth_login from "./routes/api/auth/login.tsx"; +import * as $api_auth_regen from "./routes/api/auth/regen.ts"; import * as $api_auth_signout from "./routes/api/auth/signout.ts"; import * as $api_events_create from "./routes/api/events/create.ts"; import * as $api_events_delete from "./routes/api/events/delete.ts"; @@ -46,6 +47,9 @@ import * as $index from "./routes/index.tsx"; import * as $kv_insights_layout from "./routes/kv-insights/_layout.tsx"; import * as $kv_insights_middleware from "./routes/kv-insights/_middleware.ts"; import * as $login from "./routes/login.tsx"; +import * as $user_settings_layout from "./routes/user/settings/_layout.tsx"; +import * as $user_settings_authentication from "./routes/user/settings/authentication.ts"; +import * as $user_settings_index from "./routes/user/settings/index.tsx"; import * as $components_dropinUI_trash from "./islands/components/dropinUI/trash.tsx"; import * as $components_pickers_calender from "./islands/components/pickers/calender.tsx"; import * as $components_pickers_dropdown from "./islands/components/pickers/dropdown.tsx"; @@ -97,6 +101,7 @@ const manifest = { "./routes/_app.tsx": $_app, "./routes/_layout.tsx": $_layout, "./routes/api/auth/login.tsx": $api_auth_login, + "./routes/api/auth/regen.ts": $api_auth_regen, "./routes/api/auth/signout.ts": $api_auth_signout, "./routes/api/events/create.ts": $api_events_create, "./routes/api/events/delete.ts": $api_events_delete, @@ -141,6 +146,9 @@ const manifest = { "./routes/kv-insights/_layout.tsx": $kv_insights_layout, "./routes/kv-insights/_middleware.ts": $kv_insights_middleware, "./routes/login.tsx": $login, + "./routes/user/settings/_layout.tsx": $user_settings_layout, + "./routes/user/settings/authentication.ts": $user_settings_authentication, + "./routes/user/settings/index.tsx": $user_settings_index, }, islands: { "./islands/components/dropinUI/trash.tsx": $components_dropinUI_trash, diff --git a/islands/components/pickers/dropdown.tsx b/islands/components/pickers/dropdown.tsx index ab3e967..f85535a 100644 --- a/islands/components/pickers/dropdown.tsx +++ b/islands/components/pickers/dropdown.tsx @@ -13,7 +13,7 @@ export default function Dropdown({ content: ComponentChild; onClick?: () => void; link?: string; - className?: string + className?: string; }[]; children: ComponentChild; className?: string; diff --git a/islands/components/pieces/navDropDown.tsx b/islands/components/pieces/navDropDown.tsx index 550525f..889a371 100644 --- a/islands/components/pieces/navDropDown.tsx +++ b/islands/components/pieces/navDropDown.tsx @@ -1,16 +1,15 @@ -import { UserPartial } from "@/utils/db/kv.types.ts"; +import { User } from "@/utils/db/kv.types.ts"; import Selector from "$tabler/selector.tsx"; import Dropdown from "@/islands/components/pickers/dropdown.tsx"; import CirclePlus from "$tabler/circle-plus.tsx"; import Settings from "$tabler/settings.tsx"; import UserCircle from "$tabler/user-circle.tsx"; -import Logout from "$tabler/logout-2.tsx" +import Logout from "$tabler/logout-2.tsx"; import { useSignal } from "@preact/signals"; import { deleteCookie } from "$std/http/cookie.ts"; -const NavbarDropDown = ({ user }: { user: UserPartial }) => { +const NavbarDropDown = ({ user }: { user: User }) => { const open = useSignal(false); - const headers = new Headers(); return ( {

Settings

), - onClick: () => alert("Settings is coming soon!"), + link: "/user/settings", }, { content: ( @@ -40,7 +39,11 @@ const NavbarDropDown = ({ user }: { user: UserPartial }) => { ), className: "bg-red-100 hover:!bg-red-200", - onClick: () => {deleteCookie(headers, "authToken", {path: "/"})}, + onClick: () => { + document.cookie = + "authToken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; + location.href = "/"; + }, //link: "/" }, ]} diff --git a/islands/events/creation/three.tsx b/islands/events/creation/three.tsx index ef7d2de..793b86b 100644 --- a/islands/events/creation/three.tsx +++ b/islands/events/creation/three.tsx @@ -1,5 +1,5 @@ import { Signal } from "@preact/signals"; -import { StateUpdater, useState, useEffect } from "preact/hooks"; +import { StateUpdater, useEffect, useState } from "preact/hooks"; import { Event } from "@/utils/db/kv.types.ts"; import ImagePicker from "../../components/pickers/image.tsx"; import CTA from "@/components/buttons/cta.tsx"; diff --git a/islands/events/editing/settings.tsx b/islands/events/editing/settings.tsx index 49431ad..b706321 100644 --- a/islands/events/editing/settings.tsx +++ b/islands/events/editing/settings.tsx @@ -1,11 +1,7 @@ -import { signal, useSignal } from "@preact/signals"; import CTA from "@/components/buttons/cta.tsx"; -import useForm from "@/components/hooks/fakeFormik/index.tsx"; -import { Event } from "@/utils/db/kv.types.ts"; import { useState } from "preact/hooks"; import { FirstPageEventValidation } from "@/utils/types/events.ts"; import { removeKeysWithSameValues } from "@/utils/misc.ts"; -import * as Yup from "yup"; import { JSX } from "preact"; import { Loading } from "@/utils/loading.ts"; diff --git a/islands/events/editing/ticketSettings.tsx b/islands/events/editing/ticketSettings.tsx index 6b225c7..2b33799 100644 --- a/islands/events/editing/ticketSettings.tsx +++ b/islands/events/editing/ticketSettings.tsx @@ -1,18 +1,13 @@ -import { signal, useSignal } from "@preact/signals"; import CTA from "@/components/buttons/cta.tsx"; -import useForm from "@/components/hooks/fakeFormik/index.tsx"; import { Event, Field } from "@/utils/db/kv.types.ts"; import { StateUpdater, useState } from "preact/hooks"; -import { FirstPageEventValidation } from "@/utils/types/events.ts"; import { removeKeysWithSameValues } from "@/utils/misc.ts"; -import * as Yup from "yup"; -import { JSX } from "preact"; import { Loading } from "@/utils/loading.ts"; import { Toggle } from "@/components/buttons/toggle.tsx"; import { AdditionalInputs, - FieldInput, defaultField, + FieldInput, } from "@/islands/events/creation/two.tsx"; import Plus from "$tabler/plus.tsx"; diff --git a/islands/events/scanning.tsx b/islands/events/scanning.tsx index 9ced01a..1824ab9 100644 --- a/islands/events/scanning.tsx +++ b/islands/events/scanning.tsx @@ -197,8 +197,9 @@ export default function Scanner({ eventID }: { eventID: string }) { const highestX = code.boundingBox.right; const highestY = code.boundingBox.bottom; - if (x < lowestX || x > highestX || y < lowestY || y > highestY) + if (x < lowestX || x > highestX || y < lowestY || y > highestY) { continue; + } console.log("Found code!", code.rawValue); @@ -302,13 +303,12 @@ export default function Scanner({ eventID }: { eventID: string }) { topY -= padding; bottomY += padding; - + ctx.lineWidth = 5; ctx.beginPath(); ctx.roundRect(leftX, topY, rightX - leftX, bottomY - topY, 20); ctx.stroke(); ctx.closePath(); - switch (codeData.status) { case "loading": { diff --git a/islands/events/viewing/register.tsx b/islands/events/viewing/register.tsx index f73dc59..70f7d2e 100644 --- a/islands/events/viewing/register.tsx +++ b/islands/events/viewing/register.tsx @@ -45,13 +45,10 @@ export default function EventRegister({ const toggles = useSignal>({ ...additionalFields .filter((field) => field.type == "toggle") - .reduce( - (acc, field) => { - acc[field.id] = false; - return acc; - }, - {} as Record, - ), + .reduce((acc, field) => { + acc[field.id] = false; + return acc; + }, {} as Record), }); const perfEntries = performance.getEntriesByType("navigation"); @@ -77,13 +74,10 @@ export default function EventRegister({ email: email || "", ...additionalFields .filter((field) => field.type != "toggle") - .reduce( - (acc, field) => { - acc[field.id] = field.type === "number" ? 0 : ""; - return acc; - }, - {} as Record, - ), + .reduce((acc, field) => { + acc[field.id] = field.type === "number" ? 0 : ""; + return acc; + }, {} as Record), }, onSubmit: (form) => createTicket(form.formState!), // TODO: add client side validation diff --git a/islands/events/viewing/showtimes.tsx b/islands/events/viewing/showtimes.tsx index 31d794d..531e237 100644 --- a/islands/events/viewing/showtimes.tsx +++ b/islands/events/viewing/showtimes.tsx @@ -1,5 +1,5 @@ import { Event, Roles, User } from "@/utils/db/kv.ts"; -import { happened, fmtDate, fmtTime } from "@/utils/dates.ts"; +import { fmtDate, fmtTime, happened } from "@/utils/dates.ts"; import { Availability } from "@/islands/events/viewing/availability.tsx"; import { EventContext } from "@/routes/events/[id]/_layout.tsx"; import { acquired } from "@/utils/tickets.ts"; diff --git a/islands/loginForm.tsx b/islands/loginForm.tsx index 266ee0c..a2ad112 100644 --- a/islands/loginForm.tsx +++ b/islands/loginForm.tsx @@ -25,9 +25,9 @@ const LoginForm = ({ attending }: { attending: boolean }) => { if (code.value.length != 0 || !/^[0-9]{6}$/g.test(clipboard)) return; login(undefined, clipboard); }; - window.addEventListener("focus", onFocus); + globalThis.addEventListener("focus", onFocus); return () => { - window.removeEventListener("focus", onFocus); + globalThis.removeEventListener("focus", onFocus); }; }, []); diff --git a/routes/api/auth/login.tsx b/routes/api/auth/login.tsx index 34ad39c..e574914 100644 --- a/routes/api/auth/login.tsx +++ b/routes/api/auth/login.tsx @@ -49,7 +49,9 @@ export const handler: Handlers<{ email: string; otp: string }> = { const otp = await generateOTP(email); // jank - const otpHTML = emailHTML.replace("{{OTP-PART-1}}", otp.slice(0,5)).replace("{{OTP-PART-2}}", otp.slice(5)); + const otpHTML = emailHTML + .replace("{{OTP-PART-1}}", otp.slice(0, 5)) + .replace("{{OTP-PART-2}}", otp.slice(5)); try { await sendEmail([email], "Your Events Authorization Code", { @@ -140,4 +142,3 @@ export const handler: Handlers<{ email: string; otp: string }> = { return resp; }, }; - diff --git a/routes/api/auth/regen.ts b/routes/api/auth/regen.ts new file mode 100644 index 0000000..76be24e --- /dev/null +++ b/routes/api/auth/regen.ts @@ -0,0 +1,32 @@ +import { Handlers } from "$fresh/server.ts"; +import { deleteCookie } from "$std/http/cookie.ts"; +import { generateAuthToken, getUser, getUserAuthToken } from "@/utils/db/kv.ts"; + +export const handler: Handlers = { + async GET(req, _ctx) { + const token = getUserAuthToken(req); + + if (token == undefined) { + return new Response(JSON.stringify({ error: "Not logged in" }), { + status: 400, + }); + } + + const user = await getUser(req); + + if (user == undefined) { + deleteCookie(req.headers, "authToken"); + return new Response(JSON.stringify({ error: "User not found" }), { + status: 400, + }); + } + + await generateAuthToken(user.email, true); + + deleteCookie(req.headers, "authToken"); + + return new Response(JSON.stringify({ status: 200 }), { + status: 200, + }); + }, +}; diff --git a/routes/api/events/create.ts b/routes/api/events/create.ts index 03cb425..198e5bf 100644 --- a/routes/api/events/create.ts +++ b/routes/api/events/create.ts @@ -1,11 +1,11 @@ import { Handlers } from "$fresh/server.ts"; import { Event, - Roles, - User, getUser, kv, PlanMaxEvents, + Roles, + User, } from "@/utils/db/kv.ts"; import { FullEventValidation } from "@/utils/types/events.ts"; diff --git a/routes/api/events/scan.ts b/routes/api/events/scan.ts index 407152a..4b16c3f 100644 --- a/routes/api/events/scan.ts +++ b/routes/api/events/scan.ts @@ -54,7 +54,10 @@ export const handler: Handlers = { ); } - const isValidTicket = ticketID.split("_").map((s) => isUUID(s)).includes(false); + const isValidTicket = ticketID + .split("_") + .map((s) => isUUID(s)) + .includes(false); if (!isValidTicket) { return new Response( diff --git a/routes/api/events/ticket/delete.ts b/routes/api/events/ticket/delete.ts index 259f2b4..8f22b28 100644 --- a/routes/api/events/ticket/delete.ts +++ b/routes/api/events/ticket/delete.ts @@ -54,6 +54,5 @@ export const handler: Handlers = { return new Response(JSON.stringify({ error: "occurred" }), { status: 400, }); - }, }; diff --git a/routes/api/events/ticket/index.ts b/routes/api/events/ticket/index.ts index 4a08b41..0495630 100644 --- a/routes/api/events/ticket/index.ts +++ b/routes/api/events/ticket/index.ts @@ -4,9 +4,9 @@ import { getUser, getUserAuthToken, kv, + Plan, Roles, User, - Plan, } from "@/utils/db/kv.ts"; import * as Yup from "yup"; import { EventRegisterError } from "@/utils/event/register.ts"; diff --git a/routes/events/[id]/(no-layout)/tickets/[tixid].tsx b/routes/events/[id]/(no-layout)/tickets/[tixid].tsx index 27dfb2b..81e1919 100644 --- a/routes/events/[id]/(no-layout)/tickets/[tixid].tsx +++ b/routes/events/[id]/(no-layout)/tickets/[tixid].tsx @@ -1,10 +1,10 @@ -import { RouteContext, defineRoute } from "$fresh/server.ts"; +import { defineRoute, RouteContext } from "$fresh/server.ts"; import { - EventContext, badEventRequest, + EventContext, } from "@/routes/events/[id]/_layout.tsx"; import { getShowtimeID } from "@/utils/tickets.ts"; -import { Ticket, kv } from "@/utils/db/kv.ts"; +import { kv, Ticket } from "@/utils/db/kv.ts"; import { Head } from "$fresh/runtime.ts"; import Footer from "@/components/layout/footer.tsx"; import TicketComponent from "../../../../../islands/components/pieces/ticket.tsx"; diff --git a/routes/events/[id]/_layout.tsx b/routes/events/[id]/_layout.tsx index a563888..02c1dd9 100644 --- a/routes/events/[id]/_layout.tsx +++ b/routes/events/[id]/_layout.tsx @@ -1,5 +1,5 @@ import { defineLayout } from "$fresh/server.ts"; -import { Event, Roles, User, getUser, kv } from "@/utils/db/kv.ts"; +import { Event, getUser, kv, Roles, User } from "@/utils/db/kv.ts"; import CTA from "@/components/buttons/cta.tsx"; import { isUUID } from "@/utils/db/misc.ts"; import { router } from "$fresh/src/server/router.ts"; diff --git a/routes/events/[id]/editing.tsx b/routes/events/[id]/editing.tsx index 300ebf9..084a90d 100644 --- a/routes/events/[id]/editing.tsx +++ b/routes/events/[id]/editing.tsx @@ -1,7 +1,7 @@ -import { RouteContext, defineRoute } from "$fresh/server.ts"; +import { defineRoute, RouteContext } from "$fresh/server.ts"; import { - EventContext, badEventRequest, + EventContext, } from "@/routes/events/[id]/_layout.tsx"; import EditingImagePicker from "@/islands/events/editing/images.tsx"; import imageKit from "@/utils/imagekit.ts"; diff --git a/routes/events/[id]/scanning.tsx b/routes/events/[id]/scanning.tsx index b74aa5c..fb26241 100644 --- a/routes/events/[id]/scanning.tsx +++ b/routes/events/[id]/scanning.tsx @@ -1,7 +1,7 @@ -import { RouteContext, defineRoute } from "$fresh/server.ts"; +import { defineRoute, RouteContext } from "$fresh/server.ts"; import { - EventContext, badEventRequest, + EventContext, } from "@/routes/events/[id]/_layout.tsx"; import Scanner from "@/islands/events/scanning.tsx"; import EventHeader from "@/components/layout/eventEditNavbar.tsx"; @@ -17,9 +17,7 @@ export default defineRoute((req, ctx: RouteContext) => {
- +
); }); diff --git a/routes/events/[id]/team.tsx b/routes/events/[id]/team.tsx index 3cd7a71..f02a405 100644 --- a/routes/events/[id]/team.tsx +++ b/routes/events/[id]/team.tsx @@ -1,7 +1,7 @@ import { defineRoute, RouteContext } from "$fresh/server.ts"; import { - EventContext, badEventRequest, + EventContext, } from "@/routes/events/[id]/_layout.tsx"; import EventHeader from "@/components/layout/eventEditNavbar.tsx"; import Button from "@/components/buttons/button.tsx"; @@ -13,7 +13,7 @@ import { Trashcan } from "@/islands/components/dropinUI/trash.tsx"; import Invite from "@/islands/events/teams/invite.tsx"; import ManageUser from "@/islands/events/teams/manage.tsx"; import Crown from "$tabler/crown.tsx"; -import { Roles, Event } from "@/utils/db/kv.ts"; +import { Event, Roles } from "@/utils/db/kv.ts"; import TeamFilters from "@/islands/events/teams/filters.tsx"; import { signal } from "@preact/signals"; @@ -71,8 +71,8 @@ export default defineRoute((req, ctx: RouteContext) => {

Add Team Members

- Invite a team member! They'll receive an emil promptly after you invite - them. + Invite a team member! They'll receive an emil promptly after you + invite them.

diff --git a/routes/events/[id]/tickets.tsx b/routes/events/[id]/tickets.tsx index e42d821..dd1e9f3 100644 --- a/routes/events/[id]/tickets.tsx +++ b/routes/events/[id]/tickets.tsx @@ -1,7 +1,7 @@ import { defineRoute, RouteContext } from "$fresh/server.ts"; import { - EventContext, badEventRequest, + EventContext, } from "@/routes/events/[id]/_layout.tsx"; import EventHeader from "@/components/layout/eventEditNavbar.tsx"; import Dropdown from "@/islands/components/pickers/dropdown.tsx"; diff --git a/routes/events/notfound.tsx b/routes/events/notfound.tsx index 2f11b57..bdd3f40 100644 --- a/routes/events/notfound.tsx +++ b/routes/events/notfound.tsx @@ -3,7 +3,9 @@ import CTA from "@/components/buttons/cta.tsx"; export default function NotFound() { return (
-

The event ID is invalid or you're not authorized to access this event

+

+ The event ID is invalid or you're not authorized to access this event +

Homepage diff --git a/routes/user/settings/_layout.tsx b/routes/user/settings/_layout.tsx new file mode 100644 index 0000000..75f3120 --- /dev/null +++ b/routes/user/settings/_layout.tsx @@ -0,0 +1,14 @@ +import { defineLayout } from "$fresh/server.ts"; + +export default defineLayout((req, ctx) => { + return ( +
+
+ s +
+
+ +
+
) + ; +}); diff --git a/routes/user/settings/authentication.ts b/routes/user/settings/authentication.ts new file mode 100644 index 0000000..e69de29 diff --git a/routes/user/settings/index.tsx b/routes/user/settings/index.tsx new file mode 100644 index 0000000..c871266 --- /dev/null +++ b/routes/user/settings/index.tsx @@ -0,0 +1,9 @@ +const Settings = () => { + return ( +
+ test +
+ ) +} + +export default Settings; \ No newline at end of file diff --git a/static/styles.css b/static/styles.css index 2ed1a8e..0748f09 100644 --- a/static/styles.css +++ b/static/styles.css @@ -35,21 +35,20 @@ textarea { border: none; -moz-appearance: textfield; appearance: textfield; - color: transparent + color: transparent; } .hideInput::-webkit-outer-spin-button, .hideInput::-webkit-inner-spin-button { - -webkit-appearance: none; - margin: 0; + -webkit-appearance: none; + margin: 0; } .hideInput::selection { color: transparent; - background-color: transparent + background-color: transparent; } - .label-text { @apply font-medium text-sm mb-0.5 capitalize; } diff --git a/utils/db/kv.ts b/utils/db/kv.ts index cd93b91..7de1557 100644 --- a/utils/db/kv.ts +++ b/utils/db/kv.ts @@ -1,4 +1,4 @@ -import { AuthCode, Plan, User, UserPartial } from "./kv.types.ts"; +import { AuthCode, Plan, User } from "./kv.types.ts"; import { getCookies, setCookie } from "$std/http/cookie.ts"; export * from "./kv.types.ts"; @@ -37,7 +37,7 @@ export const getUser = async (req: Request) => { return undefined; } - const user = await kv.get(["user", atob(email)]); + const user = await kv.get(["user", atob(email)]); if (user.value == undefined) { return undefined; @@ -55,7 +55,7 @@ export const getUser = async (req: Request) => { export const createUser = async (email: string) => { const userAuthToken = (await generateAuthToken(email, false))!; - const userInfo: UserPartial = { + const userInfo: User = { email, authToken: userAuthToken, events: [], @@ -75,7 +75,7 @@ export const getUserEmailCode = async ( authCode: string, req: Request, ) => { - const [authCodeData, user] = await kv.getMany<[AuthCode, UserPartial]>([ + const [authCodeData, user] = await kv.getMany<[AuthCode, User]>([ ["authCode", authCode, email], ["user", email], ]); diff --git a/utils/db/kv.types.ts b/utils/db/kv.types.ts index ef88431..809fcbc 100644 --- a/utils/db/kv.types.ts +++ b/utils/db/kv.types.ts @@ -87,18 +87,7 @@ export interface Ticket { } /** ["user", email] */ -export type User = UserPartial | UnonboardedUser; - -export interface UnonboardedUser { - /** Stored as eventId_showtimeId_ticketId */ - tickets: string[]; - events: string[]; - onboarded: false; - email: string; - plan: Plan; -} - -export interface UserPartial { +export interface User { email: string; /** Stored as eventId_showtimeId_ticketId */ tickets: string[]; diff --git a/utils/db/misc.ts b/utils/db/misc.ts index 712e140..a6dec22 100644 --- a/utils/db/misc.ts +++ b/utils/db/misc.ts @@ -9,9 +9,9 @@ export const isUUID = (uuid: string) => { export const isTicketUUID = (uuid: string) => { if (uuid.length != 110) return false; - for (const segment of uuid.split('_')) { + for (const segment of uuid.split("_")) { if (!isUUID(segment)) return false; } return true; -}; \ No newline at end of file +}; diff --git a/utils/email/client.ts b/utils/email/client.ts index 586b09d..92c94f1 100644 --- a/utils/email/client.ts +++ b/utils/email/client.ts @@ -1,7 +1,7 @@ import { - SESClient, SendEmailCommand, SendEmailRequest, + SESClient, } from "npm:@aws-sdk/client-ses"; export const sesClient = new SESClient({ @@ -14,10 +14,10 @@ export const sesClient = new SESClient({ /** * Send an email - * @param to - * @param subject + * @param to + * @param subject * @param message Specific a fallback text version (required) and the html - * @returns + * @returns */ export const sendEmail = async ( to: string[], @@ -25,9 +25,9 @@ export const sendEmail = async ( message: { fallback: string; html?: string }, ) => { const params: SendEmailRequest = { - // Due to fresh config stuff - Source: // Deno.env.get("AWS_EMAIL_SOURCE") || - `"Events" `, + // Due to fresh config stuff + // Deno.env.get("AWS_EMAIL_SOURCE") || + Source: `"Events" `, Destination: { ToAddresses: to, },