From f1c5467009a0b2417958fbfae6b017b921bd01f6 Mon Sep 17 00:00:00 2001 From: Ethan Niser <100045248+ethanniser@users.noreply.github.com> Date: Thu, 21 Sep 2023 15:54:10 +0000 Subject: [PATCH] idek --- bun.lockb | Bin 151996 -> 151996 bytes package.json | 2 +- src/components/base.tsx | 9 +++++++-- src/components/tweets.tsx | 38 +++++++++++++++++++++++++++---------- src/controllers/auth.tsx | 7 +++++-- src/controllers/tweets.tsx | 8 +++++++- src/db/schema/index.ts | 18 +++++++++++++++++- src/db/schema/tweets.ts | 1 + 8 files changed, 66 insertions(+), 17 deletions(-) diff --git a/bun.lockb b/bun.lockb index a780a30965df2cec38b87666abf932cf6b8b2ba3..f1bd967cdd513b46dfaaf0ea274205256bd2e642 100755 GIT binary patch delta 199 zcmdn9m~+o!&Ix)7$=9QE%9_vGZ!UjR;p}24-1yL=`1bLI>t(JVcz=7b=JbtzS?Y`u zlNBY^Cnrd9Y<{60+u&gP;m6FK4ZCZvN4=VvJHI-0>n~IB9Rg9y=b7DmqO4}hv-rX6 z_il$Tm~E53`Y-iB{mxrLLKpR3>OEg87cV#|Og?RM>k9p1Rn0I4IA~yGH-U4Y3^pLm lw4G6g(VS(wfC8g+HKWOPpV^Ej0;U(fV^rL3`i8MR6#ykAOJM*2 delta 199 zcmdn9m~+o!&Ix)76HVKBpLqysTsiRmxlH#Hk&6|4yDV!|H8X!H&UCALTDs9MOPx_{ zvZAE=+ZkmT%~`e!C@@-AGa7C8nay}2V7em@lhSsxH;iqm0MzJ7%K!iX diff --git a/package.json b/package.json index 93f4d30..00471af 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@lucia-auth/adapter-sqlite": "^2.0.0", "@t3-oss/env-core": "^0.6.1", "@tlscipher/holt": "1.1.0", - "beth-stack": "0.0.22", + "beth-stack": "0.0.24", "drizzle-orm": "^0.28.6", "drizzle-typebox": "^0.1.1", "elysia": "0.7.4", diff --git a/src/components/base.tsx b/src/components/base.tsx index fda217c..ef5bfe3 100644 --- a/src/components/base.tsx +++ b/src/components/base.tsx @@ -2,8 +2,13 @@ import { liveReloadScript } from "beth-stack/dev"; import { type PropsWithChildren } from "beth-stack/jsx"; import { config } from "../config"; + const safeScript = - config.env.NODE_ENV === "development" ? liveReloadScript() : ""; + config.env.NODE_ENV === "development" + ? liveReloadScript({ + url: "https://upgraded-orbit-qw9457vrwv39669-3001.app.github.dev/ws", + }) + : ""; export const BaseHtml = ({ children }: PropsWithChildren) => ( @@ -25,4 +30,4 @@ export const BaseHtml = ({ children }: PropsWithChildren) => ( {children} -); +); \ No newline at end of file diff --git a/src/components/tweets.tsx b/src/components/tweets.tsx index 07eba80..583b0d1 100644 --- a/src/components/tweets.tsx +++ b/src/components/tweets.tsx @@ -1,24 +1,44 @@ import { db } from "../db"; -import { tweets, type Tweet } from "../db/schema/tweets"; +import { tweets } from "../db/schema/tweets"; -export function TweetCard({ authorId, createdAt, content }: Tweet) { +export function TweetCard({ + author: { handle }, + createdAt, + content, +}: { + createdAt: Date; + content: string; + author: { + handle: string; + }; +}) { return (

- {authorId} + @{handle}

{content}

- {new Date(createdAt).toLocaleString()} + {createdAt.toLocaleString()}
); } export async function TweetList() { - const tweetData = await db.select().from(tweets).limit(10); + const tweetData = await db.query.tweets.findMany({ + limit: 10, + orderBy: (tweets, { desc }) => [desc(tweets.createdAt)], + with: { + author: { + columns: { + handle: true, + }, + }, + }, + }); return (
@@ -33,17 +53,15 @@ export function TweetCreationForm() { return (

Create a new Tweet

-
+ - + />