rhythia-api 103.0.0 → 104.0.0

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.
@@ -7,19 +7,23 @@ import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
7
7
  import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
8
8
 
9
9
  const s3Client = new S3Client({
10
- region: "us-east-1",
10
+ endpoint: "https://s3.eu-central-003.backblazeb2.com",
11
11
  credentials: {
12
- secretAccessKey: "0036dd2cb06d730015861d27ce0796cccb5031123e",
13
- accessKeyId: "c245e893e806",
12
+ secretAccessKey: "K0039mm4iKsteQOXpZSzf0+VDzuH89U",
13
+ accessKeyId: "003c245e893e8060000000001",
14
14
  },
15
15
  });
16
16
 
17
17
  export const Schema = {
18
18
  input: z.strictObject({
19
19
  session: z.string(),
20
+ contentLength: z.number(),
21
+ contentType: z.string(),
20
22
  }),
21
23
  output: z.strictObject({
22
- url: z.string(),
24
+ error: z.string().optional(),
25
+ url: z.string().optional(),
26
+ objectKey: z.string().optional(),
23
27
  }),
24
28
  };
25
29
 
@@ -34,15 +38,24 @@ export async function POST(request: Request): Promise<NextResponse> {
34
38
 
35
39
  export async function handler({
36
40
  session,
41
+ contentLength,
42
+ contentType,
37
43
  }: (typeof Schema)["input"]["_type"]): Promise<
38
44
  NextResponse<(typeof Schema)["output"]["_type"]>
39
45
  > {
40
46
  const user = (await supabase.auth.getUser(session)).data.user!;
41
47
 
48
+ if (contentLength > 5000000) {
49
+ return NextResponse.json({
50
+ error: "Max content length exceeded.",
51
+ });
52
+ }
53
+
42
54
  const command = new PutObjectCommand({
43
- Bucket: "rhythia-avatars",
55
+ Bucket: "rhthia-avatars",
44
56
  Key: `user-avatar-${Date.now()}-${user.id}`,
45
- ContentLength: 5000000,
57
+ ContentLength: contentLength,
58
+ ContentType: contentType,
46
59
  });
47
60
 
48
61
  const presigned = await getSignedUrl(s3Client, command, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "103.0.0",
3
+ "version": "104.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",