Skip to content

Commit

Permalink
lint + format
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguyinabeanie committed Nov 8, 2024
1 parent 9277a67 commit 6dcdcf0
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 157 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"prettiercache",
"subrouters",
"thatguyinabenaie",
"tsbuildinfo",
"tseslint",
"typesafe",
"unauthed",
"Ursaluna"
]
Expand Down
102 changes: 7 additions & 95 deletions apps/expo/src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { useState } from "react";
import { Button, Pressable, Text, TextInput, View } from "react-native";
import { Button, Pressable, Text, View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { Link, Stack } from "expo-router";
import { FlashList } from "@shopify/flash-list";

import type { RouterOutputs } from "~/utils/api";
import { api } from "~/utils/api";
// import type { RouterOutputs } from "~/utils/api";
// import { api } from "~/utils/api";
import { useSignIn, useSignOut, useUser } from "~/utils/auth";

function PostCard(
export function PostCard(
props: Readonly<{
post: RouterOutputs["post"]["all"][number];
onDelete: () => void;
}>,
) {
Expand All @@ -21,14 +18,11 @@ function PostCard(
asChild
href={{
pathname: "/post/[id]",
params: { id: props.post.id },
}}
>
<Pressable className="">
<Text className="text-xl font-semibold text-primary">
{props.post.title}
</Text>
<Text className="mt-2 text-foreground">{props.post.content}</Text>
<Text className="text-xl font-semibold text-primary">Title</Text>
<Text className="mt-2 text-foreground">CONTENT</Text>
</Pressable>
</Link>
</View>
Expand All @@ -39,64 +33,6 @@ function PostCard(
);
}

function CreatePost() {
const utils = api.useUtils();

const [title, setTitle] = useState("");
const [content, setContent] = useState("");

const { mutate, error } = api.post.create.useMutation({
async onSuccess() {
setTitle("");
setContent("");
await utils.post.all.invalidate();
},
});

return (
<View className="mt-4 flex gap-2">
<TextInput
className="items-center rounded-md border border-input bg-background px-3 text-lg leading-[1.25] text-foreground"
value={title}
onChangeText={setTitle}
placeholder="Title"
/>
{error?.data?.zodError?.fieldErrors.title && (
<Text className="mb-2 text-destructive">
{error.data.zodError.fieldErrors.title}
</Text>
)}
<TextInput
className="items-center rounded-md border border-input bg-background px-3 text-lg leading-[1.25] text-foreground"
value={content}
onChangeText={setContent}
placeholder="Content"
/>
{error?.data?.zodError?.fieldErrors.content && (
<Text className="mb-2 text-destructive">
{error.data.zodError.fieldErrors.content}
</Text>
)}
<Pressable
className="flex items-center rounded bg-primary p-2"
onPress={() => {
mutate({
title,
content,
});
}}
>
<Text className="text-foreground">Create</Text>
</Pressable>
{error?.data?.code === "UNAUTHORIZED" && (
<Text className="mt-2 text-destructive">
You need to be logged in to create a post
</Text>
)}
</View>
);
}

function MobileAuth() {
const user = useUser();
const signIn = useSignIn();
Expand All @@ -117,13 +53,7 @@ function MobileAuth() {
}

export default function Index() {
const utils = api.useUtils();

const postQuery = api.post.all.useQuery();

const deletePostMutation = api.post.delete.useMutation({
onSettled: () => utils.post.all.invalidate(),
});
// const utils = api.useUtils();

return (
<SafeAreaView className="bg-background">
Expand All @@ -141,25 +71,7 @@ export default function Index() {
Press on a post
</Text>
</View>

<FlashList
data={postQuery.data}
estimatedItemSize={20}
ItemSeparatorComponent={ItemSeparatorComponent}
renderItem={(p) => (
<PostCard
post={p.item}
onDelete={() => deletePostMutation.mutate(p.item.id)}
/>
)}
/>

<CreatePost />
</View>
</SafeAreaView>
);
}

function ItemSeparatorComponent() {
return <View className="h-2" />;
}
24 changes: 0 additions & 24 deletions apps/expo/src/app/post/[id].tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/expo/src/utils/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export { type RouterInputs, type RouterOutputs } from "@battle-stadium/api";
* A wrapper for your app that provides the TRPC context.
* Use only in _app.tsx
*/
export function TRPCProvider(props: { children: React.ReactNode }) {
export function TRPCProvider(props: Readonly<{ children: React.ReactNode }>) {
const [queryClient] = useState(() => new QueryClient());
const [trpcClient] = useState(() =>
api.createClient({
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GeistSans } from "geist/font/sans";

import { cn, ThemeProvider, ThemeToggle } from "@battle-stadium/ui";

import { env } from "~/env.ts";
import { env } from "~/env";
import { TRPCReactProvider } from "~/trpc/react";

import "~/app/globals.css";
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/components/cookies/cookies-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { headers } from "next/headers";
import { NextResponse } from "next/server";
import * as cookie from "cookie";

import { env } from "~/env.ts";
import { env } from "~/env";

function getCookieDomain() {
if (env.NODE_ENV === "production") {
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/lib/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getVercelOidcToken } from "@vercel/functions/oidc";
import createFetchClient from "openapi-fetch";

import type { paths } from "~/lib/api/openapi-v1";
import { env } from "~/env.ts";
import { env } from "~/env";

export const DEFAULT_CACHE_TIMEOUT = 300;

Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/lib/websocket/websocket-url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { env } from "~/env.ts";
import { env } from "~/env";

const DEFAULT_WS_PORT = "10000";
const DEFAULT_WS_PATH = "/cable";
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";

import { env } from "./env.ts";
import { env } from "./env";

// Or like this if you need to do something here.
// export default auth((req) => {
Expand Down
12 changes: 0 additions & 12 deletions apps/nextjs/src/trpc/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Session } from "@clerk/nextjs/server";
import { cache } from "react";
import { headers } from "next/headers";
import { createHydrationHelpers } from "@trpc/react-query/rsc";
Expand All @@ -17,17 +16,6 @@ const createContext = cache(async () => {
heads.set("x-trpc-source", "rsc");

return createTRPCContext({
session: {
id: "1",
clientId: "1",
userId: "1",
status: "hello",
lastActiveAt: 1,
expireAt: 1,
abandonAt: 1,
createdAt: 1,
updatedAt: 1,
} as Session,
headers: heads,
});
});
Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { initTRPC, TRPCError } from "@trpc/server";
import superjson from "superjson";
import { ZodError } from "zod";

// import type { Session } from "@battle-stadium/auth";
// import { auth, validateToken } from "@battle-stadium/auth";
import { db } from "@battle-stadium/db/client";

/**
Expand All @@ -24,9 +22,9 @@ import { db } from "@battle-stadium/db/client";
const isomorphicGetSession = async (headers: Headers) => {
const authToken = headers.get("Authorization") ?? null;
if (authToken) {
console.log(">>> tRPC Request with token", authToken);
// return validateToken(authToken);
}
// return auth();
return await auth();
};

Expand Down
1 change: 1 addition & 0 deletions packages/auth/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import baseConfig, {
/** @type {import('typescript-eslint').Config} */
export default [
{
files: ["src/**/*.ts", "env.ts"],
ignores: [],
},
...baseConfig,
Expand Down
Empty file removed packages/auth/inde
Empty file.
17 changes: 1 addition & 16 deletions packages/auth/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
import { DrizzleAdapter } from "@auth/drizzle-adapter";

import { db } from "@battle-stadium/db/client";
import { Account, Session, User } from "@battle-stadium/db/schema";

import { env } from "../env";

const adapter = DrizzleAdapter(db, {
usersTable: User,
accountsTable: Account,
sessionsTable: Session,
});

export const isSecureContext = env.NODE_ENV !== "development";

export { adapter };
export * from "../env";
1 change: 0 additions & 1 deletion tooling/typescript/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"target": "ES2022",
"lib": ["ES2022"],
"allowJs": true,
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
Expand Down

0 comments on commit 6dcdcf0

Please sign in to comment.