Skip to content

Commit 1592b8d

Browse files
committed
feat: autumn provider in api
1 parent 64cdfe5 commit 1592b8d

File tree

6 files changed

+27
-228
lines changed

6 files changed

+27
-228
lines changed

apps/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@elysiajs/trpc": "^1.1.0",
1919
"@logtail/edge": "^0.5.5",
2020
"@trpc/server": "^11.4.3",
21-
"autumn-js": "0.0.101-beta.1",
21+
"autumn-js": "^0.1.10",
2222
"dayjs": "^1.11.13",
2323
"elysia": "^1.3.6",
2424
"openai": "^5.9.0"

apps/api/src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import './polyfills/compression';
2+
import { auth } from '@databuddy/auth';
23
import { appRouter, createTRPCContext } from '@databuddy/rpc';
34
import cors from '@elysiajs/cors';
45
import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
6+
import { autumnHandler } from 'autumn-js/elysia';
57
import { Elysia } from 'elysia';
68
import { logger } from './lib/logger';
79
import { assistant } from './routes/assistant';
@@ -20,6 +22,23 @@ const app = new Elysia()
2022
],
2123
})
2224
)
25+
.use(
26+
autumnHandler({
27+
identify: async ({ request }) => {
28+
const session = await auth.api.getSession({
29+
headers: request.headers,
30+
});
31+
32+
return {
33+
customerId: session?.user.id,
34+
customerData: {
35+
name: session?.user.name,
36+
email: session?.user.email,
37+
},
38+
};
39+
},
40+
})
41+
)
2342

2443
.use(query)
2544
.use(assistant)

apps/dashboard/app/actions/preferences.ts

Lines changed: 0 additions & 160 deletions
This file was deleted.

apps/dashboard/app/actions/users.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { revalidatePath } from 'next/cache';
66
import { headers } from 'next/headers';
77
import { cache } from 'react';
88
import { z } from 'zod';
9-
// import { uploadOptimizedImage } from "@/lib/supabase";
10-
// import type { CropData, ImageEditOptions } from "@/types/image";
119
import { logger } from '@/lib/discord-webhook';
1210

1311
// Helper to get authenticated user
@@ -34,68 +32,6 @@ const profileUpdateSchema = z.object({
3432
image: z.string().url('Please enter a valid image URL').optional(),
3533
});
3634

37-
/**
38-
* Uploads a profile image to Supabase storage with optional cropping and editing
39-
*/
40-
// export async function uploadProfileImage(formData: FormData) {
41-
// const user = await getUser();
42-
// if (!user) return { error: "Unauthorized" };
43-
44-
// try {
45-
// const file = formData.get("file") as File;
46-
// if (!file) {
47-
// return { error: "No file provided" };
48-
// }
49-
50-
// // Validate file type
51-
// if (!file.type.startsWith("image/")) {
52-
// return { error: "Please upload an image file" };
53-
// }
54-
55-
// // Validate file size (max 5MB)
56-
// if (file.size > 5 * 1024 * 1024) {
57-
// return { error: "Image size must be less than 5MB" };
58-
// }
59-
60-
// // Get crop data if provided
61-
// // let cropData: CropData | undefined;
62-
// const cropDataStr = formData.get("cropData");
63-
// if (cropDataStr && typeof cropDataStr === "string") {
64-
// try {
65-
// cropData = JSON.parse(cropDataStr);
66-
// } catch (e) {
67-
// console.error("Failed to parse crop data", e);
68-
// }
69-
// }
70-
71-
// // Get edit options if provided
72-
// let edits: ImageEditOptions | undefined;
73-
// const editsStr = formData.get("edits");
74-
// if (editsStr && typeof editsStr === "string") {
75-
// try {
76-
// edits = JSON.parse(editsStr);
77-
// } catch (e) {
78-
// console.error("Failed to parse edit options", e);
79-
// }
80-
// }
81-
82-
// // Upload to Supabase using the server-side function
83-
// const result = await uploadOptimizedImage(
84-
// file,
85-
// ["medium"],
86-
// "profile-images",
87-
// user.id,
88-
// cropData,
89-
// edits
90-
// );
91-
92-
// return { url: result.medium };
93-
// } catch (error) {
94-
// console.error("Profile image upload error:", error);
95-
// return { error: "Failed to upload image" };
96-
// }
97-
// }
98-
9935
/**
10036
* Updates the user's profile information
10137
*/

apps/dashboard/app/providers.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ export default function Providers({ children }: { children: React.ReactNode }) {
6565
<trpc.Provider client={trpcClient} queryClient={queryClient}>
6666
<QueryClientProvider client={queryClient}>
6767
<SessionProvider session={null}>
68-
<AutumnProvider>
68+
<AutumnProvider
69+
backendUrl={
70+
process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001'
71+
}
72+
>
6973
<NuqsAdapter>{children}</NuqsAdapter>
7074
</AutumnProvider>
7175
</SessionProvider>

bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@elysiajs/trpc": "^1.1.0",
2121
"@logtail/edge": "^0.5.5",
2222
"@trpc/server": "^11.4.3",
23-
"autumn-js": "0.0.101-beta.1",
23+
"autumn-js": "^0.1.10",
2424
"dayjs": "^1.11.13",
2525
"elysia": "^1.3.6",
2626
"openai": "^5.9.0",
@@ -1470,7 +1470,7 @@
14701470

14711471
"auto-bind": ["[email protected]", "", {}, "sha512-ooviqdwwgfIfNmDwo94wlshcdzfO64XV0Cg6oDsDYBJfITDz1EngD2z7DkbvCWn+XIMsIqW27sEVF6qcpJrRcg=="],
14721472

1473-
"autumn-js": ["autumn-js@0.0.101-beta.1", "", { "dependencies": { "axios": "^1.10.0", "chalk": "^5.4.1", "commander": "^14.0.0", "ink": "^6.0.1", "jiti": "^2.4.2", "open": "^10.1.2", "rou3": "^0.6.1", "swr": "^2.3.3", "zod": "^3.24.1" }, "peerDependencies": { "better-auth": "^1.2.12", "better-call": "^1.0.12" }, "optionalPeers": ["better-auth", "better-call"] }, "sha512-r5/7FCrB55bVkZrreKr/kcbtWBTPjrT0iW4+G0o5bTwzzhgLOO3LTtmwyMKH28ybnYmIy6FZ8CVIoD1pNf2WZA=="],
1473+
"autumn-js": ["autumn-js@0.1.10", "", { "dependencies": { "rou3": "^0.6.1", "swr": "^2.3.3", "zod": "^3.24.1" }, "peerDependencies": { "better-auth": "^1.2.12", "better-call": "^1.0.12" }, "optionalPeers": ["better-auth", "better-call"] }, "sha512-7MUc+xQz49ER44rr5bLmQClXPUSIvjrHGKlCbFzyEE5sNkjKJb8kltxOu2ueZYBJ76bUiTzEig4mfI6tmcOt6A=="],
14741474

14751475
"available-typed-arrays": ["[email protected]", "", { "dependencies": { "possible-typed-array-names": "^1.0.0" } }, "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ=="],
14761476

0 commit comments

Comments
 (0)