feat: resolve public url for avatar
This commit is contained in:
parent
4a8f7447e9
commit
9ad11b8f9e
@ -33,6 +33,8 @@ spec:
|
||||
value: "3005"
|
||||
- name: REDIS_URL
|
||||
value: redis://happy-redis:6379
|
||||
- name: S3_PUBLIC_URL
|
||||
value: https://files.happy-servers.com/happy
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: handy-secrets
|
||||
|
@ -37,6 +37,7 @@ import { encryptBytes, encryptString } from "@/modules/encrypt";
|
||||
import { GitHubProfile } from "./types";
|
||||
import { uploadImage } from "@/storage/uploadImage";
|
||||
import { separateName } from "@/utils/separateName";
|
||||
import { getPublicUrl } from "@/storage/files";
|
||||
|
||||
|
||||
declare module 'fastify' {
|
||||
@ -1000,7 +1001,7 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
|
||||
timestamp: Date.now(),
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
avatar: user.avatar,
|
||||
avatar: user.avatar ? { ...user.avatar, url: getPublicUrl(user.avatar.path) } : null,
|
||||
github: user.githubUser ? user.githubUser.profile : null
|
||||
});
|
||||
});
|
||||
|
@ -2,6 +2,7 @@ import { Socket } from "socket.io";
|
||||
import { log } from "@/utils/log";
|
||||
import { GitHubProfile } from "@/app/types";
|
||||
import { AccountProfile } from "@/types";
|
||||
import { getPublicUrl } from "@/storage/files";
|
||||
|
||||
// === CONNECTION TYPES ===
|
||||
|
||||
@ -338,7 +339,8 @@ export function buildUpdateAccountUpdate(userId: string, profile: Partial<Accoun
|
||||
body: {
|
||||
t: 'update-account',
|
||||
id: userId,
|
||||
...profile
|
||||
...profile,
|
||||
avatar: profile.avatar ? { ...profile.avatar, url: getPublicUrl(profile.avatar.path) } : undefined
|
||||
},
|
||||
createdAt: Date.now()
|
||||
};
|
||||
|
@ -11,10 +11,16 @@ export const s3bucket = process.env.S3_BUCKET!;
|
||||
|
||||
export const s3host = process.env.S3_HOST!
|
||||
|
||||
export const s3public = process.env.S3_PUBLIC_URL!;
|
||||
|
||||
export async function loadFiles() {
|
||||
await s3client.bucketExists(s3bucket); // Throws if bucket does not exist or is not accessible
|
||||
}
|
||||
|
||||
export function getPublicUrl(path: string) {
|
||||
return `${s3public}/${path}`;
|
||||
}
|
||||
|
||||
export type ImageRef = {
|
||||
width: number;
|
||||
height: number;
|
||||
|
Loading…
Reference in New Issue
Block a user