diff --git a/local/redis/dumps/dump.rdb b/local/redis/dumps/dump.rdb index 6d54789..911d9b8 100644 Binary files a/local/redis/dumps/dump.rdb and b/local/redis/dumps/dump.rdb differ diff --git a/src/api/controllers/backup.controller.ts b/src/api/controllers/backup.controller.ts index f93c978..aa877db 100644 --- a/src/api/controllers/backup.controller.ts +++ b/src/api/controllers/backup.controller.ts @@ -1,5 +1,5 @@ import { Request, Response } from 'express'; -import { getLastDump, deleteFileBackup, getFileBackup, updateFileBackup, uploadFileBackup } from '../utils/backup-storage'; +import { getLastDump, deleteFileBackup, getFileBackup, updateFileBackup, uploadFileBackup } from '../delegated-storage/index'; import fs from 'fs'; import { BackupProps } from '../props/backup'; diff --git a/src/api/utils/backup-storage/distant-backend/utils.ts b/src/api/delegated-storage/distant-backend/utils.ts similarity index 94% rename from src/api/utils/backup-storage/distant-backend/utils.ts rename to src/api/delegated-storage/distant-backend/utils.ts index b6efdd3..0423c6a 100644 --- a/src/api/utils/backup-storage/distant-backend/utils.ts +++ b/src/api/delegated-storage/distant-backend/utils.ts @@ -1,8 +1,8 @@ import fetch, { Headers } from 'node-fetch'; -import { BackupProps } from '../../../props/backup'; -import { connectClient, disconnectClient } from '../../redis/connection'; -import { addMultipleFiles } from '../../redis/operations'; -import { logger } from '../../logs/winston'; +import { BackupProps } from '../../props/backup'; +import { connectClient, disconnectClient } from '../../utils/redis/connection'; +import { addMultipleFiles } from '../../utils/redis/operations'; +import { logger } from '../../utils/logs/winston'; interface UploadFileProps { filepath: string; diff --git a/src/api/utils/backup-storage/index.ts b/src/api/delegated-storage/index.ts similarity index 98% rename from src/api/utils/backup-storage/index.ts rename to src/api/delegated-storage/index.ts index b67746f..a74453f 100644 --- a/src/api/utils/backup-storage/index.ts +++ b/src/api/delegated-storage/index.ts @@ -1,6 +1,6 @@ import * as distantBackend from './distant-backend/utils'; import * as s3 from './s3/utils'; -import { logger } from '../logs/winston'; +import { logger } from '../utils/logs/winston'; export interface FilePathProps { filepath: string; diff --git a/src/api/utils/backup-storage/s3/connection.ts b/src/api/delegated-storage/s3/connection.ts similarity index 100% rename from src/api/utils/backup-storage/s3/connection.ts rename to src/api/delegated-storage/s3/connection.ts diff --git a/src/api/utils/backup-storage/s3/utils.ts b/src/api/delegated-storage/s3/utils.ts similarity index 95% rename from src/api/utils/backup-storage/s3/utils.ts rename to src/api/delegated-storage/s3/utils.ts index 1551a4b..a0e4072 100644 --- a/src/api/utils/backup-storage/s3/utils.ts +++ b/src/api/delegated-storage/s3/utils.ts @@ -1,9 +1,9 @@ import { minioClient } from './connection'; import { FileProps } from '../types'; import { promisify } from 'node:util'; -import { addMultipleFiles, getLastVersion } from '../../redis/operations'; -import { connectClient, disconnectClient } from '../../redis/connection'; -import app from '../../../app'; +import { addMultipleFiles, getLastVersion } from '../../utils/redis/operations'; +import { connectClient, disconnectClient } from '../../utils/redis/connection'; +import app from '../../app'; export const getLastDump = async () => { const getObjectAsync = promisify(minioClient.getObject.bind(minioClient)); diff --git a/src/api/utils/backup-storage/types.ts b/src/api/delegated-storage/types.ts similarity index 100% rename from src/api/utils/backup-storage/types.ts rename to src/api/delegated-storage/types.ts diff --git a/src/api/server.ts b/src/api/server.ts index 18cd7b0..f64fe89 100644 --- a/src/api/server.ts +++ b/src/api/server.ts @@ -2,8 +2,8 @@ import app from './app'; import { logger } from './utils/logs/winston'; import fs from 'fs'; import { redisClient } from './utils/redis/connection'; -import { getLastDump } from './utils/backup-storage'; -import { minioClient } from './utils/backup-storage/s3/connection'; +import { getLastDump } from './delegated-storage/index'; +import { minioClient } from './delegated-storage/s3/connection'; import { expressListRoutes } from './utils/list-routes'; import fetch from 'node-fetch'; diff --git a/src/api/tests/api.test.ts b/src/api/tests/api.test.ts deleted file mode 100644 index 5f3ff89..0000000 --- a/src/api/tests/api.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -const request = require('supertest'); -const express = require('express'); -const app = express(); - -describe('API Routes', () => { - test('GET /readiness-check should return 200', async () => { - const response = await request(app).get('/readiness-check'); - expect(response.status).toBe(200); - }); - - test('GET /backup/get-last-dump should return 200', async () => { - const response = await request(app).get('/backup/get-last-dump'); - expect(response.status).toBe(200); - }); - - test('GET /backup should return 200', async () => { - const response = await request(app).get('/backup'); - expect(response.status).toBe(200); - }); - - test('POST /backup should handle POST request', async () => { - const response = await request(app).post('/backup').send({}); - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('PATCH /backup should handle PATCH request', async () => { - const response = await request(app).patch('/backup').send({}); - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('DELETE /backup should handle DELETE request', async () => { - const response = await request(app).delete('/backup').send({}); - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('GET /catalog should return 200', async () => { - const response = await request(app).get('/catalog'); - expect(response.status).toBe(200); - }); - - test('GET /catalog/create-dump should return 200', async () => { - const response = await request(app).get('/catalog/create-dump'); - expect(response.status).toBe(200); - }); - - test('GET /catalog/:id should return 200', async () => { - const response = await request(app).get('/catalog/1'); // Remplacez "1" par un ID valide - expect(response.status).toBe(200); - }); - - test('GET /assets/media/* should return 200', async () => { - const response = await request(app).get('/assets/media/testfile'); // Remplacez "testfile" par un fichier valide - expect(response.status).toBe(200); - }); - - test('POST /upload should handle upload request', async () => { - const response = await request(app).post('/upload').send({}); - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('PATCH /:uuid should handle patch request', async () => { - const response = await request(app).patch('/123e4567-e89b-12d3-a456-426614174000').send({}); // Remplacez par un UUID valide - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('DELETE /:uuid should handle delete request', async () => { - const response = await request(app).delete('/123e4567-e89b-12d3-a456-426614174000').send({}); // Remplacez par un UUID valide - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('POST /uploads should handle uploads request', async () => { - const response = await request(app).post('/uploads').send({}); - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('PATCH / should handle patch request', async () => { - const response = await request(app).patch('/').send({}); - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('DELETE / should handle delete request', async () => { - const response = await request(app).delete('/').send({}); - expect(response.status).toBe(200); // Changez selon la réponse attendue - }); - - test('GET /list-routes should return 200', async () => { - const response = await request(app).get('/list-routes'); - expect(response.status).toBe(200); - }); -});