7 Commits

Author SHA1 Message Date
Mathis HERRIOT
c03ad8c221 fix(content): update type field and conditional rendering for content handling
Some checks failed
CI/CD Pipeline / Valider backend (push) Successful in 1m26s
CI/CD Pipeline / Valider frontend (push) Failing after 1m10s
CI/CD Pipeline / Valider documentation (push) Successful in 1m34s
CI/CD Pipeline / Déploiement en Production (push) Has been skipped
- Changed `type` field values from `image | video` to `meme | gif`.
- Updated conditional rendering in `content-card` component to match new `type` values.
2026-01-20 22:04:25 +01:00
Mathis HERRIOT
8483927823 fix(tests): replace any with Record<string, unknown> in repository tests
All checks were successful
CI/CD Pipeline / Valider backend (push) Successful in 1m39s
CI/CD Pipeline / Valider frontend (push) Successful in 1m43s
CI/CD Pipeline / Valider documentation (push) Successful in 1m46s
CI/CD Pipeline / Déploiement en Production (push) Successful in 1m32s
- Updated type assertions in repository test files to use `Record<string, unknown>` instead of `any`.
2026-01-20 21:42:16 +01:00
Mathis HERRIOT
e7b79013fd build(release): bump package versions to 1.0.6
Some checks failed
CI/CD Pipeline / Valider backend (push) Failing after 1m1s
CI/CD Pipeline / Valider frontend (push) Successful in 1m45s
CI/CD Pipeline / Valider documentation (push) Successful in 1m45s
CI/CD Pipeline / Déploiement en Production (push) Has been skipped
2026-01-20 21:28:47 +01:00
Mathis HERRIOT
b6b37ebc6b docs(api): update /media endpoint documentation to use path query parameter
Some checks failed
CI/CD Pipeline / Valider backend (push) Failing after 56s
CI/CD Pipeline / Valider frontend (push) Successful in 1m38s
CI/CD Pipeline / Valider documentation (push) Successful in 1m41s
CI/CD Pipeline / Déploiement en Production (push) Has been skipped
2026-01-20 21:28:23 +01:00
Mathis HERRIOT
d647a585c8 fix(media): handle missing path parameter and improve error logging
- Updated `getFile` method to validate `path` query parameter.
- Added improved logging for file retrieval errors.
- Updated test cases to cover scenarios with missing `path`.
2026-01-20 21:28:10 +01:00
Mathis HERRIOT
6a2abf115f fix(s3): update public URL to include path query parameter
- Updated `getPublicUrl` to use `?path=<key>` format in public URLs.
- Adjusted corresponding test cases to reflect the new URL structure.
2026-01-20 21:27:49 +01:00
Mathis HERRIOT
ded2d3220d build(release): bump package versions to 1.0.5
All checks were successful
CI/CD Pipeline / Valider backend (push) Successful in 1m39s
CI/CD Pipeline / Valider frontend (push) Successful in 1m46s
CI/CD Pipeline / Valider documentation (push) Successful in 1m50s
CI/CD Pipeline / Déploiement en Production (push) Successful in 1m57s
2026-01-20 20:00:36 +01:00
15 changed files with 49 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@memegoat/backend",
"version": "1.0.4",
"version": "1.0.6",
"description": "",
"author": "",
"private": true,

View File

@@ -23,7 +23,7 @@ describe("ApiKeysRepository", () => {
// biome-ignore lint/suspicious/noThenProperty: Necessary to mock Drizzle's awaitable query builder
Object.defineProperty(obj, "then", {
value: function (onFulfilled: (arg0: unknown) => void) {
const result = (this as any).execute();
const result = (this as Record<string, unknown>).execute();
return Promise.resolve(result).then(onFulfilled);
},
configurable: true,

View File

@@ -24,7 +24,7 @@ describe("CategoriesRepository", () => {
// biome-ignore lint/suspicious/noThenProperty: Necessary to mock Drizzle's awaitable query builder
Object.defineProperty(obj, "then", {
value: function (onFulfilled: (arg0: unknown) => void) {
const result = (this as any).execute();
const result = (this as Record<string, unknown>).execute();
return Promise.resolve(result).then(onFulfilled);
},
configurable: true,

View File

@@ -21,10 +21,9 @@ describe("FavoritesRepository", () => {
const wrapWithThen = (obj: unknown) => {
// biome-ignore lint/suspicious/noThenProperty: Necessary to mock Drizzle's awaitable query builder
// biome-ignore lint/suspicious/noExplicitAny: Necessary to mock Drizzle's awaitable query builder
Object.defineProperty(obj, "then", {
value: function (onFulfilled: (arg0: unknown) => void) {
const result = (this as any).execute();
const result = (this as Record<string, unknown>).execute();
return Promise.resolve(result).then(onFulfilled);
},
configurable: true,

View File

@@ -49,6 +49,11 @@ describe("MediaController", () => {
expect(stream.pipe).toHaveBeenCalledWith(res);
});
it("should throw NotFoundException if path is missing", async () => {
const res = {} as unknown as Response;
await expect(controller.getFile("", res)).rejects.toThrow(NotFoundException);
});
it("should throw NotFoundException if file is not found", async () => {
mockS3Service.getFileInfo.mockRejectedValue(new Error("Not found"));
const res = {} as unknown as Response;

View File

@@ -1,27 +1,47 @@
import { Controller, Get, NotFoundException, Param, Res } from "@nestjs/common";
import {
Controller,
Get,
Logger,
NotFoundException,
Query,
Res,
} from "@nestjs/common";
import type { Response } from "express";
import type { BucketItemStat } from "minio";
import { S3Service } from "../s3/s3.service";
@Controller("media")
export class MediaController {
private readonly logger = new Logger(MediaController.name);
constructor(private readonly s3Service: S3Service) {}
@Get("*key")
async getFile(@Param("key") key: string, @Res() res: Response) {
try {
const stats = (await this.s3Service.getFileInfo(key)) as BucketItemStat;
const stream = await this.s3Service.getFile(key);
@Get()
async getFile(@Query("path") path: string, @Res() res: Response) {
if (!path) {
this.logger.warn("Tentative d'accès à un média sans paramètre 'path'");
throw new NotFoundException("Paramètre 'path' manquant");
}
const contentType =
stats.metaData?.["content-type"] || "application/octet-stream";
try {
this.logger.log(`Récupération du fichier : ${path}`);
const stats = (await this.s3Service.getFileInfo(path)) as BucketItemStat;
const stream = await this.s3Service.getFile(path);
const contentType: string =
stats.metaData?.["content-type"] ||
stats.metaData?.["Content-Type"] ||
"application/octet-stream";
res.setHeader("Content-Type", contentType);
res.setHeader("Content-Length", stats.size);
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
stream.pipe(res);
} catch (_error) {
} catch (error) {
this.logger.error(
`Erreur lors de la récupération du fichier ${path} : ${error.message}`,
);
throw new NotFoundException("Fichier non trouvé");
}
}

View File

@@ -23,10 +23,9 @@ describe("ReportsRepository", () => {
const wrapWithThen = (obj: unknown) => {
// biome-ignore lint/suspicious/noThenProperty: Necessary to mock Drizzle's awaitable query builder
// biome-ignore lint/suspicious/noExplicitAny: Necessary to mock Drizzle's awaitable query builder
Object.defineProperty(obj, "then", {
value: function (onFulfilled: (arg0: unknown) => void) {
const result = (this as any).execute();
const result = (this as Record<string, unknown>).execute();
return Promise.resolve(result).then(onFulfilled);
},
configurable: true,

View File

@@ -192,7 +192,7 @@ describe("S3Service", () => {
return null;
});
const url = service.getPublicUrl("test.webp");
expect(url).toBe("https://api.test.com/media/test.webp");
expect(url).toBe("https://api.test.com/media?path=test.webp");
});
it("should use DOMAIN_NAME and PORT for localhost", () => {
@@ -205,7 +205,7 @@ describe("S3Service", () => {
},
);
const url = service.getPublicUrl("test.webp");
expect(url).toBe("http://localhost:3000/media/test.webp");
expect(url).toBe("http://localhost:3000/media?path=test.webp");
});
it("should use api.DOMAIN_NAME for production", () => {
@@ -217,7 +217,7 @@ describe("S3Service", () => {
},
);
const url = service.getPublicUrl("test.webp");
expect(url).toBe("https://api.memegoat.fr/media/test.webp");
expect(url).toBe("https://api.memegoat.fr/media?path=test.webp");
});
});
});

View File

@@ -173,6 +173,6 @@ export class S3Service implements OnModuleInit, IStorageService {
baseUrl = `https://api.${domain}`;
}
return `${baseUrl}/media/${storageKey}`;
return `${baseUrl}/media?path=${storageKey}`;
}
}

View File

@@ -239,7 +239,7 @@ Cette page documente tous les points de terminaison disponibles sur l'API Memego
</Accordion>
<Accordion title="Médias (/media)">
- `GET /media/*key` : Accès direct aux fichiers stockés sur S3. Supporte la mise en cache agressive.
- `GET /media?path=key` : Accès direct aux fichiers stockés sur S3 via le paramètre `path`. Supporte la mise en cache agressive.
</Accordion>
<Accordion title="Administration (/admin)">

View File

@@ -24,7 +24,7 @@ Le système utilise plusieurs méthodes d'authentification sécurisées pour ré
Memegoat utilise une architecture de stockage d'objets compatible S3 (MinIO). Les interactions se font de deux manières :
1. **Proxification Backend** : Pour l'accès public via `/media/*`.
1. **Proxification Backend** : Pour l'accès public via `/media?path=...`.
2. **URLs Présignées** : Pour l'upload sécurisé direct depuis le client (via `/contents/upload-url`).
### Notifications (Mail)

View File

@@ -1,6 +1,6 @@
{
"name": "@memegoat/frontend",
"version": "1.0.4",
"version": "1.0.6",
"private": true,
"scripts": {
"dev": "next dev",

View File

@@ -95,7 +95,7 @@ export function ContentCard({ content }: ContentCardProps) {
</CardHeader>
<CardContent className="p-0 relative bg-zinc-100 dark:bg-zinc-900 aspect-square flex items-center justify-center">
<Link href={`/meme/${content.slug}`} className="w-full h-full relative">
{content.type === "image" ? (
{content.type === "meme" ? (
<Image
src={content.url}
alt={content.title}

View File

@@ -7,7 +7,7 @@ export interface Content {
description?: string;
url: string;
thumbnailUrl?: string;
type: "image" | "video";
type: "meme" | "gif";
mimeType: string;
size: number;
width?: number;

View File

@@ -1,6 +1,6 @@
{
"name": "@memegoat/source",
"version": "1.0.4",
"version": "1.0.6",
"description": "",
"scripts": {
"version:get": "cmake -P version.cmake GET",