startx 1.0.5 → 1.0.9

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.
Files changed (48) hide show
  1. package/apps/core-server/Dockerfile +9 -3
  2. package/apps/core-server/src/config/custom-type.ts +1 -1
  3. package/apps/core-server/src/middlewares/auth-middleware.ts +74 -30
  4. package/apps/queue-worker/Dockerfile +16 -9
  5. package/apps/queue-worker/package.json +5 -1
  6. package/apps/queue-worker/src/bullmq/board.ts +28 -0
  7. package/apps/queue-worker/src/index.ts +2 -0
  8. package/apps/startx-cli/dist/index.mjs +3 -3
  9. package/apps/startx-cli/src/configs/scripts.ts +44 -4
  10. package/apps/web-client/Dockerfile +40 -0
  11. package/apps/web-client/nginx.conf +20 -0
  12. package/apps/web-client/package.json +1 -1
  13. package/apps/web-client/src/app.css +0 -1
  14. package/assets/avatars/54b19ada-d53e-4ee9-8882-9dfed1bf1396.jpg +0 -0
  15. package/assets/avatars/ad3bf027-e85b-4cad-ab5f-80a25e37f4cb.jpg +0 -0
  16. package/assets/avatars/e67eb556-f125-4e24-95ad-8aff21b9926a.jpg +0 -0
  17. package/package.json +8 -2
  18. package/packages/@db/drizzle/drizzle.config.ts +1 -1
  19. package/packages/@db/drizzle/src/index.ts +4 -15
  20. package/packages/@repo/env/src/default-env.ts +1 -0
  21. package/packages/@repo/lib/src/cookie-module/cookie-module.ts +94 -38
  22. package/packages/@repo/lib/src/extra/index.ts +1 -0
  23. package/packages/@repo/lib/src/extra/token-module.ts +50 -21
  24. package/packages/@repo/lib/src/mail-module/nodemailer.ts +36 -23
  25. package/packages/@repo/lib/src/session-module/i-session.ts +132 -59
  26. package/packages/@repo/lib/src/session-module/index.ts +8 -2
  27. package/packages/@repo/lib/src/session-module/redis-session.ts +53 -23
  28. package/packages/@repo/lib/src/validation-module/index.ts +50 -78
  29. package/packages/@repo/lib/tsconfig.json +2 -1
  30. package/packages/@repo/model/eslint.config.ts +4 -0
  31. package/packages/@repo/model/package.json +41 -0
  32. package/packages/@repo/model/src/index.ts +0 -0
  33. package/packages/@repo/model/tsconfig.json +7 -0
  34. package/packages/@repo/model/vitest.config.ts +3 -0
  35. package/packages/common/src/time.ts +95 -22
  36. package/packages/queue/src/adapter/bullmq-adapter.ts +138 -47
  37. package/packages/queue/src/index.ts +3 -0
  38. package/packages/queue/src/queue-interface.ts +12 -5
  39. package/packages/queue/src/registry.ts +2 -2
  40. package/packages/queue/tsconfig.json +1 -1
  41. package/packages/ui/src/api/use-api/react-query/types.ts +3 -3
  42. package/packages/ui/src/api/use-api/react-query/use-api.ts +10 -11
  43. package/pnpm-workspace.yaml +4 -2
  44. package/turbo.json +21 -1
  45. package/packages/@repo/lib/src/bucket-module/file-storage.ts +0 -50
  46. package/packages/@repo/lib/src/bucket-module/index.ts +0 -3
  47. package/packages/@repo/lib/src/bucket-module/s3-storage.ts +0 -120
  48. package/packages/@repo/lib/src/bucket-module/utils.ts +0 -10
@@ -1,120 +0,0 @@
1
- /**
2
- * TODO: connect to bucket
3
- */
4
- import {
5
- DeleteObjectCommand,
6
- PutObjectCommand,
7
- type PutObjectCommandInput,
8
- S3Client,
9
- } from "@aws-sdk/client-s3";
10
- import { defineEnv } from "@repo/env";
11
- import z from "zod";
12
-
13
- const credentials = defineEnv({
14
- AWS_ACCESS_KEY_ID: z.string(),
15
- AWS_SECRET_ACCESS_KEY: z.string(),
16
- AWS_REGION: z.string().default("us-east-1"),
17
- AWS_BUCKET: z.string(),
18
- S3_ENDPOINT: z.string().optional(),
19
- });
20
-
21
- const s3Endpoint = credentials.S3_ENDPOINT;
22
- const s3Client = new S3Client({
23
- credentials: {
24
- accessKeyId: credentials.AWS_ACCESS_KEY_ID,
25
- secretAccessKey: credentials.AWS_SECRET_ACCESS_KEY,
26
- },
27
- region: credentials.AWS_REGION,
28
- endpoint: s3Endpoint,
29
- });
30
-
31
- const bucket = credentials.AWS_BUCKET;
32
-
33
- export type UploadFile = {
34
- name: string;
35
- mimetype: string;
36
- data: Buffer;
37
- };
38
-
39
- export class S3Bucket {
40
- static async uploadFile(file: UploadFile, path: string) {
41
- let key = `${path}`;
42
- if (!key.includes(".")) {
43
- key += ".jpeg";
44
- }
45
- const params = {
46
- Bucket: bucket,
47
- Key: key,
48
- Body: file.data,
49
- ContentType: file.mimetype,
50
- } as PutObjectCommandInput;
51
- const command = new PutObjectCommand(params);
52
- await s3Client.send(command);
53
- const fileUrl = S3Bucket.getAwsUrl(key);
54
- return fileUrl;
55
- }
56
-
57
- static getAwsUrl(path: string) {
58
- return `https://${bucket}.s3.${credentials.AWS_REGION}.amazonaws.com/${path}`;
59
- }
60
-
61
- static getKeyFromUrl(url: string) {
62
- const key = url.split(`https://${bucket}.s3.${credentials.AWS_REGION}.amazonaws.com/`)[1];
63
- return key;
64
- }
65
-
66
- static async uploadFiles({ path, files }: { path: string; files: UploadFile[] }) {
67
- try {
68
- if (!path) throw new Error("Path must be provided.");
69
- if (!files) throw new Error("File must be provided.");
70
- // const buffers: UploadFile[] = [];
71
- // for (const key in file) {
72
- // const item = file[key];
73
- // if (Array.isArray(item)) item.forEach((e) => buffers.push(e));
74
- // else buffers.push(item!);
75
- // }
76
-
77
- // let upload = [] as { url: string; type: string; name: string }[];
78
- const upload = await Promise.all(
79
- files.map(async file => {
80
- const key = file.name;
81
- const params: PutObjectCommandInput = {
82
- Bucket: bucket,
83
- Key: `${path}/${key}`,
84
- Body: file.data,
85
- ContentType: file.mimetype,
86
- };
87
- const command = new PutObjectCommand(params);
88
- await s3Client.send(command);
89
- return {
90
- url: S3Bucket.getAwsUrl(`${path}/${key}`),
91
- type: file.mimetype,
92
- name: file.name,
93
- };
94
- })
95
- );
96
- return upload;
97
- // if (upload.length > 0) return upload;
98
- // else throw new Error("Something went wrong.");
99
- } catch (error) {
100
- console.log(error);
101
- throw error;
102
- }
103
- }
104
-
105
- // ! don't use
106
- static async deleteFile(path: string) {
107
- try {
108
- const params = {
109
- Bucket: bucket,
110
- Key: path,
111
- };
112
-
113
- const command = new DeleteObjectCommand(params);
114
- await s3Client.send(command);
115
- } catch (error) {
116
- console.log(error);
117
- throw error;
118
- }
119
- }
120
- }
@@ -1,10 +0,0 @@
1
- import { S3Bucket } from "./s3-storage.js";
2
-
3
- export const pathGenerator = {
4
- asset: {
5
- base: "image/assets",
6
- },
7
- profile: (userId: string) => `user/${userId}/profile`,
8
- };
9
-
10
- export const defaultAvatarUrl = `${S3Bucket.getAwsUrl("image/assets/avatar_image.png")}`;