Skip to content

Commit

Permalink
yeah
Browse files Browse the repository at this point in the history
  • Loading branch information
d3rpp committed Aug 25, 2024
1 parent 4c2d260 commit 59911f7
Show file tree
Hide file tree
Showing 31 changed files with 62 additions and 35 deletions.
3 changes: 2 additions & 1 deletion src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { lucia } from "$lib/server/auth/adapter";
import { authHook } from "$lib/server/auth/hook";
import { createContext } from "$lib/server/trpc/context";
import { router } from "$lib/server/trpc/router";
import { TRPC_PATH } from "$lib/trpc/client";

import type { Handle } from "@sveltejs/kit";
import { sequence } from "@sveltejs/kit/hooks";
Expand All @@ -17,5 +18,5 @@ setInterval(() => {

export const handle: Handle = sequence(
authHook,
createTRPCHandle({ router, createContext }),
createTRPCHandle({ router, createContext, url: TRPC_PATH }),
);
2 changes: 1 addition & 1 deletion src/lib/components/ui/avatar/avatar-fallback.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { Avatar as AvatarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
type $$Props = AvatarPrimitive.FallbackProps;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/avatar/avatar-image.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { Avatar as AvatarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
type $$Props = AvatarPrimitive.ImageProps;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/avatar/avatar.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { Avatar as AvatarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
type $$Props = AvatarPrimitive.Props;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/ui/button/button.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Button as ButtonPrimitive } from "bits-ui";
import { type Props, buttonVariants } from "./index.js";
import { cn } from "$lib/utils.js";
import { type Props, buttonVariants } from "./index";
import { cn } from "$lib/utils";
let {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/card/card-content.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
const {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/card/card-description.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
const {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/card/card-footer.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
const {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/card/card-header.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
const {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/card/card-title.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import type { HeadingLevel } from "./index.js";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
const {
class: className = undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/card/card.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
const {
class: className,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import Check from "lucide-svelte/icons/check";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
import type { CheckBoxItemProps } from ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn, flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils";
import type { ContentProps } from ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
import type { ItemProps } from ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
import type { LabelProps } from ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import Circle from "lucide-svelte/icons/circle";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
import type { RadioItemProps } from ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
import type { SeparatorProps } from ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
import type { ShortcutProps } from ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn, flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils";
import type { SubContentProps } from ".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import ChevronRight from "lucide-svelte/icons/chevron-right";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
import type { SubTriggerProps } from ".";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/input/input-file.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { HTMLInputAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
let {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/input/input.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { HTMLInputAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
let {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/label/label.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { Label as LabelPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
const {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/separator/separator.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { Separator as SeparatorPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
import { cn } from "$lib/utils";
const {
class: className,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/tooltip/tooltip-content.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { Tooltip as TooltipPrimitive } from "bits-ui";
import { cn, flyAndScale } from "$lib/utils.js";
import { cn, flyAndScale } from "$lib/utils";
const {
class: className,
Expand Down
4 changes: 3 additions & 1 deletion src/lib/server/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ sqlite.exec("PRAGMA journal_mode = WAL;");
sqlite.exec("PRAGMA foreign_keys = on;");

export const DB = drizzle(sqlite, {
logger: process.env.NODE_ENV == "development" && ["1", "true"].includes(process.env.LOGGER_ENABLED ?? ""),
logger:
process.env.NODE_ENV == "development" &&
["1", "true"].includes(process.env.LOGGER_ENABLED ?? ""),
});

/**
Expand Down
16 changes: 15 additions & 1 deletion src/lib/trpc/client.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// type imported for TSDoc, ignore this.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { page } from "$app/stores";

import type { Router } from "$lib/server/trpc/router";

import { createTRPCClient, type TRPCClientInit } from "trpc-sveltekit";
import type { QueryClient } from "@tanstack/svelte-query";
import { svelteQueryWrapper } from "trpc-svelte-query-adapter";

import { httpBatchLink, loggerLink } from "@trpc/client";

import { browser } from "$app/environment";

let browserClient: ReturnType<typeof svelteQueryWrapper<Router>>;

export const TRPC_PATH = `/__trpc`;

/**
* allows access to a client-side tRPC client
*
Expand All @@ -19,7 +25,15 @@ let browserClient: ReturnType<typeof svelteQueryWrapper<Router>>;
export const trpc = (init?: TRPCClientInit, queryClient?: QueryClient) => {
if (browser && browserClient) return browserClient;
const client = svelteQueryWrapper({
client: createTRPCClient<Router>({ init }),
client: createTRPCClient<Router>({
links: [
loggerLink(),
httpBatchLink({
url: TRPC_PATH,
fetch: init?.fetch,
}),
],
}),
queryClient,
});
if (browser) browserClient = client;
Expand Down
11 changes: 10 additions & 1 deletion src/routes/(app)/app/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
import { Button } from "$lib/components/ui/button";
import { toast } from "svelte-sonner";
const aaaa = () => {
console.error("AAAAAAAA");
toast.promise(new Promise(res => setTimeout(res, 5_000)), {
loading: "Loading",
important: true,
finally: () => {
toast.success("Done.")
}
});
};
</script>

Expand Down
10 changes: 6 additions & 4 deletions src/routes/(app)/app/account/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ export const load = (async (event) => {
const client = trpc(event, queryClient);

return {
uploadedFileCount:
await client.user.getUploadedFiles.createServerQuery(undefined, {
ssr: false
}),
uploadedFileCount: await client.user.getUploadedFiles.createServerQuery(
undefined,
{
ssr: false,
},
),
};
}) satisfies PageLoad;
1 change: 0 additions & 1 deletion src/routes/(auth)/auth/sign-up/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
*/
const username_invalid_error_text: Readable<string | undefined> =
derived_store(username_availability_query, (val) => {
console.log(val.data);
if (val.data && val.data.available === false)
return "Username is Taken";
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<ModeWatcher defaultMode="system" />

<Toaster />
<Toaster position="bottom-center" />

<QueryClientProvider client={queryClient}>
{@render children()}
Expand Down

0 comments on commit 59911f7

Please sign in to comment.