@goscribe/server 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,25 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
43
43
  };
44
44
  transformer: true;
45
45
  }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
46
+ updateProfile: import("@trpc/server").TRPCMutationProcedure<{
47
+ input: {
48
+ name: string;
49
+ };
50
+ output: {
51
+ success: boolean;
52
+ message: string;
53
+ };
54
+ meta: object;
55
+ }>;
56
+ uploadProfilePicture: import("@trpc/server").TRPCMutationProcedure<{
57
+ input: void;
58
+ output: {
59
+ success: boolean;
60
+ message: string;
61
+ signedUrl: string;
62
+ };
63
+ meta: object;
64
+ }>;
46
65
  signup: import("@trpc/server").TRPCMutationProcedure<{
47
66
  input: {
48
67
  name: string;
@@ -65,7 +84,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
65
84
  id: string;
66
85
  email: string | null;
67
86
  name: string | null;
68
- image: string | null;
69
87
  token: string;
70
88
  };
71
89
  meta: object;
@@ -77,7 +95,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
77
95
  id: string;
78
96
  email: string | null;
79
97
  name: string | null;
80
- image: string | null;
81
98
  };
82
99
  };
83
100
  meta: object;
@@ -233,8 +250,8 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
233
250
  name: string;
234
251
  id: string;
235
252
  createdAt: Date;
236
- userId: string;
237
- workspaceId: string;
253
+ userId: string | null;
254
+ workspaceId: string | null;
238
255
  mimeType: string;
239
256
  size: number;
240
257
  bucket: string | null;
@@ -499,14 +516,12 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
499
516
  id: string;
500
517
  name: string;
501
518
  email: string;
502
- image: string | null;
503
519
  role: "admin" | "member";
504
520
  joinedAt: Date;
505
521
  } | {
506
522
  id: string;
507
523
  name: string;
508
524
  email: string;
509
- image: string | null;
510
525
  role: "owner";
511
526
  joinedAt: Date;
512
527
  })[];
@@ -1724,7 +1739,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1724
1739
  user: {
1725
1740
  name: string | null;
1726
1741
  id: string;
1727
- image: string | null;
1728
1742
  } | null;
1729
1743
  } & {
1730
1744
  id: string;
@@ -1763,7 +1777,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1763
1777
  user: {
1764
1778
  name: string | null;
1765
1779
  id: string;
1766
- image: string | null;
1767
1780
  } | null;
1768
1781
  } & {
1769
1782
  id: string;
@@ -1791,7 +1804,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1791
1804
  user: {
1792
1805
  name: string | null;
1793
1806
  id: string;
1794
- image: string | null;
1795
1807
  } | null;
1796
1808
  } & {
1797
1809
  id: string;
@@ -1818,7 +1830,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1818
1830
  user: {
1819
1831
  name: string | null;
1820
1832
  id: string;
1821
- image: string | null;
1822
1833
  } | null;
1823
1834
  } & {
1824
1835
  id: string;
@@ -1839,7 +1850,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1839
1850
  user: {
1840
1851
  name: string | null;
1841
1852
  id: string;
1842
- image: string | null;
1843
1853
  } | null;
1844
1854
  } & {
1845
1855
  id: string;
@@ -20,6 +20,25 @@ export declare const auth: import("@trpc/server").TRPCBuiltRouter<{
20
20
  };
21
21
  transformer: true;
22
22
  }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
23
+ updateProfile: import("@trpc/server").TRPCMutationProcedure<{
24
+ input: {
25
+ name: string;
26
+ };
27
+ output: {
28
+ success: boolean;
29
+ message: string;
30
+ };
31
+ meta: object;
32
+ }>;
33
+ uploadProfilePicture: import("@trpc/server").TRPCMutationProcedure<{
34
+ input: void;
35
+ output: {
36
+ success: boolean;
37
+ message: string;
38
+ signedUrl: string;
39
+ };
40
+ meta: object;
41
+ }>;
23
42
  signup: import("@trpc/server").TRPCMutationProcedure<{
24
43
  input: {
25
44
  name: string;
@@ -42,7 +61,6 @@ export declare const auth: import("@trpc/server").TRPCBuiltRouter<{
42
61
  id: string;
43
62
  email: string | null;
44
63
  name: string | null;
45
- image: string | null;
46
64
  token: string;
47
65
  };
48
66
  meta: object;
@@ -54,7 +72,6 @@ export declare const auth: import("@trpc/server").TRPCBuiltRouter<{
54
72
  id: string;
55
73
  email: string | null;
56
74
  name: string | null;
57
- image: string | null;
58
75
  };
59
76
  };
60
77
  meta: object;
@@ -3,6 +3,8 @@ import { router, publicProcedure } from '../trpc.js';
3
3
  import bcrypt from 'bcryptjs';
4
4
  import { serialize } from 'cookie';
5
5
  import crypto from 'node:crypto';
6
+ import { TRPCError } from '@trpc/server';
7
+ import { supabaseClient } from 'src/lib/storage.js';
6
8
  // Helper to create custom auth token
7
9
  function createCustomAuthToken(userId) {
8
10
  const secret = process.env.AUTH_SECRET;
@@ -16,6 +18,50 @@ function createCustomAuthToken(userId) {
16
18
  return `${base64UserId}.${signature}`;
17
19
  }
18
20
  export const auth = router({
21
+ updateProfile: publicProcedure
22
+ .input(z.object({
23
+ name: z.string().min(1),
24
+ }))
25
+ .mutation(async ({ ctx, input }) => {
26
+ const { name } = input;
27
+ await ctx.db.user.update({
28
+ where: {
29
+ id: ctx.session.user.id,
30
+ },
31
+ data: {
32
+ name: name,
33
+ }
34
+ });
35
+ return {
36
+ success: true,
37
+ message: 'Profile updated successfully',
38
+ };
39
+ }),
40
+ uploadProfilePicture: publicProcedure
41
+ .mutation(async ({ ctx, input }) => {
42
+ const objectKey = `profile_picture_${ctx.session.user.id}`;
43
+ const { data: signedUrlData, error: signedUrlError } = await supabaseClient.storage
44
+ .from('media')
45
+ .createSignedUploadUrl(objectKey); // 5 minutes
46
+ if (signedUrlError) {
47
+ throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: `Failed to generate upload URL: ${signedUrlError.message}` });
48
+ }
49
+ await ctx.db.fileAsset.create({
50
+ data: {
51
+ userId: ctx.session.user.id,
52
+ name: 'Profile Picture',
53
+ mimeType: 'image/jpeg',
54
+ size: 0,
55
+ bucket: 'media',
56
+ objectKey: objectKey,
57
+ },
58
+ });
59
+ return {
60
+ success: true,
61
+ message: 'Profile picture uploaded successfully',
62
+ signedUrl: signedUrlData.signedUrl,
63
+ };
64
+ }),
19
65
  signup: publicProcedure
20
66
  .input(z.object({
21
67
  name: z.string().min(1),
@@ -72,7 +118,6 @@ export const auth = router({
72
118
  id: user.id,
73
119
  email: user.email,
74
120
  name: user.name,
75
- image: user.image,
76
121
  token: authToken
77
122
  };
78
123
  }),
@@ -92,7 +137,6 @@ export const auth = router({
92
137
  id: user.id,
93
138
  email: user.email,
94
139
  name: user.name,
95
- image: user.image
96
140
  }
97
141
  };
98
142
  }),
@@ -42,7 +42,6 @@ export declare const chat: import("@trpc/server").TRPCBuiltRouter<{
42
42
  user: {
43
43
  name: string | null;
44
44
  id: string;
45
- image: string | null;
46
45
  } | null;
47
46
  } & {
48
47
  id: string;
@@ -81,7 +80,6 @@ export declare const chat: import("@trpc/server").TRPCBuiltRouter<{
81
80
  user: {
82
81
  name: string | null;
83
82
  id: string;
84
- image: string | null;
85
83
  } | null;
86
84
  } & {
87
85
  id: string;
@@ -109,7 +107,6 @@ export declare const chat: import("@trpc/server").TRPCBuiltRouter<{
109
107
  user: {
110
108
  name: string | null;
111
109
  id: string;
112
- image: string | null;
113
110
  } | null;
114
111
  } & {
115
112
  id: string;
@@ -136,7 +133,6 @@ export declare const chat: import("@trpc/server").TRPCBuiltRouter<{
136
133
  user: {
137
134
  name: string | null;
138
135
  id: string;
139
- image: string | null;
140
136
  } | null;
141
137
  } & {
142
138
  id: string;
@@ -157,7 +153,6 @@ export declare const chat: import("@trpc/server").TRPCBuiltRouter<{
157
153
  user: {
158
154
  name: string | null;
159
155
  id: string;
160
- image: string | null;
161
156
  } | null;
162
157
  } & {
163
158
  id: string;
@@ -14,7 +14,13 @@ export const chat = router({
14
14
  select: {
15
15
  id: true,
16
16
  name: true,
17
- image: true,
17
+ profilePicture: {
18
+ select: {
19
+ id: true,
20
+ name: true,
21
+ url: true,
22
+ }
23
+ }
18
24
  }
19
25
  }
20
26
  }
@@ -40,7 +46,6 @@ export const chat = router({
40
46
  select: {
41
47
  id: true,
42
48
  name: true,
43
- image: true,
44
49
  }
45
50
  }
46
51
  }
@@ -62,7 +67,6 @@ export const chat = router({
62
67
  select: {
63
68
  id: true,
64
69
  name: true,
65
- image: true,
66
70
  }
67
71
  }
68
72
  }
@@ -96,7 +100,6 @@ export const chat = router({
96
100
  select: {
97
101
  id: true,
98
102
  name: true,
99
- image: true,
100
103
  }
101
104
  },
102
105
  }
@@ -122,7 +125,6 @@ export const chat = router({
122
125
  select: {
123
126
  id: true,
124
127
  name: true,
125
- image: true,
126
128
  }
127
129
  }
128
130
  }
@@ -150,7 +152,6 @@ export const chat = router({
150
152
  select: {
151
153
  id: true,
152
154
  name: true,
153
- image: true,
154
155
  }
155
156
  }
156
157
  }
@@ -171,7 +172,6 @@ export const chat = router({
171
172
  select: {
172
173
  id: true,
173
174
  name: true,
174
- image: true,
175
175
  }
176
176
  }
177
177
  }
@@ -190,7 +190,6 @@ export const chat = router({
190
190
  select: {
191
191
  id: true,
192
192
  name: true,
193
- image: true,
194
193
  }
195
194
  }
196
195
  }
@@ -209,7 +208,6 @@ export const chat = router({
209
208
  select: {
210
209
  id: true,
211
210
  name: true,
212
- image: true,
213
211
  }
214
212
  }
215
213
  }
@@ -228,7 +226,6 @@ export const chat = router({
228
226
  select: {
229
227
  id: true,
230
228
  name: true,
231
- image: true,
232
229
  }
233
230
  },
234
231
  }
@@ -42,14 +42,12 @@ export declare const members: import("@trpc/server").TRPCBuiltRouter<{
42
42
  id: string;
43
43
  name: string;
44
44
  email: string;
45
- image: string | null;
46
45
  role: "admin" | "member";
47
46
  joinedAt: Date;
48
47
  } | {
49
48
  id: string;
50
49
  name: string;
51
50
  email: string;
52
- image: string | null;
53
51
  role: "owner";
54
52
  joinedAt: Date;
55
53
  })[];
@@ -37,7 +37,13 @@ export const members = router({
37
37
  id: true,
38
38
  name: true,
39
39
  email: true,
40
- image: true,
40
+ profilePicture: {
41
+ select: {
42
+ id: true,
43
+ name: true,
44
+ url: true,
45
+ }
46
+ }
41
47
  }
42
48
  },
43
49
  members: {
@@ -47,7 +53,13 @@ export const members = router({
47
53
  id: true,
48
54
  name: true,
49
55
  email: true,
50
- image: true,
56
+ profilePicture: {
57
+ select: {
58
+ id: true,
59
+ name: true,
60
+ url: true,
61
+ }
62
+ }
51
63
  }
52
64
  }
53
65
  }
@@ -66,7 +78,6 @@ export const members = router({
66
78
  id: workspace.owner.id,
67
79
  name: workspace.owner.name || 'Unknown',
68
80
  email: workspace.owner.email || '',
69
- image: workspace.owner.image,
70
81
  role: 'owner',
71
82
  joinedAt: workspace.createdAt,
72
83
  },
@@ -74,7 +85,6 @@ export const members = router({
74
85
  id: membership.user.id,
75
86
  name: membership.user.name || 'Unknown',
76
87
  email: membership.user.email || '',
77
- image: membership.user.image,
78
88
  role: membership.role,
79
89
  joinedAt: membership.joinedAt,
80
90
  }))
@@ -142,8 +142,8 @@ export declare const workspace: import("@trpc/server").TRPCBuiltRouter<{
142
142
  name: string;
143
143
  id: string;
144
144
  createdAt: Date;
145
- userId: string;
146
- workspaceId: string;
145
+ userId: string | null;
146
+ workspaceId: string | null;
147
147
  mimeType: string;
148
148
  size: number;
149
149
  bucket: string | null;
@@ -408,14 +408,12 @@ export declare const workspace: import("@trpc/server").TRPCBuiltRouter<{
408
408
  id: string;
409
409
  name: string;
410
410
  email: string;
411
- image: string | null;
412
411
  role: "admin" | "member";
413
412
  joinedAt: Date;
414
413
  } | {
415
414
  id: string;
416
415
  name: string;
417
416
  email: string;
418
- image: string | null;
419
417
  role: "owner";
420
418
  joinedAt: Date;
421
419
  })[];
package/dist/server.js CHANGED
@@ -8,6 +8,7 @@ import * as trpcExpress from '@trpc/server/adapters/express';
8
8
  import { appRouter } from './routers/_app.js';
9
9
  import { createContext } from './context.js';
10
10
  import { logger } from './lib/logger.js';
11
+ import { supabaseClient } from './lib/storage.js';
11
12
  const PORT = process.env.PORT ? Number(process.env.PORT) : 3001;
12
13
  async function main() {
13
14
  const app = express();
@@ -35,6 +36,17 @@ async function main() {
35
36
  app.get('/', (_req, res) => {
36
37
  res.json({ ok: true, service: 'trpc-express', ts: Date.now() });
37
38
  });
39
+ app.get('/profile-picture/:objectKey', async (req, res) => {
40
+ const { objectKey } = req.params;
41
+ const signedUrl = await supabaseClient.storage
42
+ .from('media')
43
+ .createSignedUrl(objectKey, 60 * 60 * 24 * 30);
44
+ if (signedUrl.error) {
45
+ return res.status(500).json({ error: 'Failed to generate signed URL' });
46
+ }
47
+ // res.json({ url: signedUrl.data.signedUrl });
48
+ res.redirect(signedUrl.data.signedUrl);
49
+ });
38
50
  // tRPC mounted under /trpc
39
51
  app.use('/trpc', trpcExpress.createExpressMiddleware({
40
52
  router: appRouter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goscribe/server",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,13 @@ export const chat = router({
15
15
  select: {
16
16
  id: true,
17
17
  name: true,
18
- image: true,
18
+ profilePicture: {
19
+ select: {
20
+ id: true,
21
+ name: true,
22
+ url: true,
23
+ }
24
+ }
19
25
  }
20
26
  }
21
27
  }
@@ -41,7 +47,6 @@ export const chat = router({
41
47
  select: {
42
48
  id: true,
43
49
  name: true,
44
- image: true,
45
50
  }
46
51
  }
47
52
  }
@@ -65,7 +70,6 @@ export const chat = router({
65
70
  select: {
66
71
  id: true,
67
72
  name: true,
68
- image: true,
69
73
  }
70
74
  }
71
75
  }
@@ -101,7 +105,6 @@ export const chat = router({
101
105
  select: {
102
106
  id: true,
103
107
  name: true,
104
- image: true,
105
108
  }
106
109
  },
107
110
  }
@@ -127,7 +130,6 @@ export const chat = router({
127
130
  select: {
128
131
  id: true,
129
132
  name: true,
130
- image: true,
131
133
  }
132
134
  }
133
135
  }
@@ -155,7 +157,6 @@ export const chat = router({
155
157
  select: {
156
158
  id: true,
157
159
  name: true,
158
- image: true,
159
160
  }
160
161
  }
161
162
  }
@@ -176,7 +177,6 @@ export const chat = router({
176
177
  select: {
177
178
  id: true,
178
179
  name: true,
179
- image: true,
180
180
  }
181
181
  }
182
182
  }
@@ -195,7 +195,6 @@ export const chat = router({
195
195
  select: {
196
196
  id: true,
197
197
  name: true,
198
- image: true,
199
198
  }
200
199
  }
201
200
  }
@@ -214,7 +213,6 @@ export const chat = router({
214
213
  select: {
215
214
  id: true,
216
215
  name: true,
217
- image: true,
218
216
  }
219
217
  }
220
218
  }
@@ -233,7 +231,6 @@ export const chat = router({
233
231
  select: {
234
232
  id: true,
235
233
  name: true,
236
- image: true,
237
234
  }
238
235
  },
239
236
  }