mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-24 13:41:25 +10:00
refactor(server): use proxy mechanisms to remove server_url config
This commit is contained in:
@ -22,8 +22,8 @@ import { ResumeService } from './resume.service';
|
||||
storage: diskStorage({
|
||||
destination: async (req, _, cb) => {
|
||||
const userId = (req.user as User).id;
|
||||
const resumeId = req.params.id;
|
||||
const destination = join(__dirname, `assets/uploads/${userId}/${resumeId}`);
|
||||
const resumeId = +req.params.id;
|
||||
const destination = join(__dirname, '..', `assets/uploads/${userId}/${resumeId}`);
|
||||
|
||||
await mkdir(destination, { recursive: true });
|
||||
|
||||
|
||||
@ -218,9 +218,8 @@ export class ResumeService {
|
||||
|
||||
async uploadPhoto(id: number, userId: number, filename: string) {
|
||||
const resume = await this.findOne(id, userId);
|
||||
const serverUrl = this.configService.get<string>('app.serverUrl');
|
||||
|
||||
const url = `${serverUrl}/uploads/${userId}/${id}/${filename}`;
|
||||
const url = `/api/uploads/${userId}/${id}/${filename}`;
|
||||
const updatedResume = set(resume, 'basics.photo.url', url);
|
||||
|
||||
return this.resumeRepository.save<Resume>(updatedResume);
|
||||
@ -228,8 +227,8 @@ export class ResumeService {
|
||||
|
||||
async deletePhoto(id: number, userId: number) {
|
||||
const resume = await this.findOne(id, userId);
|
||||
const key = new URL(resume.basics.photo.url).pathname;
|
||||
const photoPath = join(__dirname, 'assets', key);
|
||||
const filepath = new URL(resume.basics.photo.url).pathname;
|
||||
const photoPath = join(__dirname, '..', `assets/${filepath}`);
|
||||
const updatedResume = set(resume, 'basics.photo.url', '');
|
||||
|
||||
await unlink(photoPath);
|
||||
|
||||
Reference in New Issue
Block a user