Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.8'

services:
python-api:
build: ./python-api
ports:
- "5000:5000"
container_name: log-analyser-api

node-client:
build: ./node-client
depends_on:
- python-api
container_name: log-analyser-client
10 changes: 10 additions & 0 deletions node-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:18-alpine

WORKDIR /app

COPY package.json .
RUN npm install

COPY . .

CMD ["node", "app.js"]
10 changes: 7 additions & 3 deletions node-client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@

const path = require('path');


// Configuration partagée chargée depuis config.json (à la racine du projet)
const config = require(path.join(__dirname, '..', 'config.json'));
const API_URL = `http://${config.api.host}:${config.api.port}${config.api.route}`;

// BUG 6 — Le nom du module importé ici est incorrect
const axios = require('axios');

async function getLogs() {
try {
const response = await axios.get(API_URL);

// BUG 7 — La propriété pour accéder au corps de la réponse avec axios
// ne s'appelle pas .body — cherchez dans la doc axios comment
// accéder aux données de la réponse
const data = response.data;

console.log('\n========================================');
Expand All @@ -22,9 +26,9 @@ async function getLogs() {
console.log(` Avertissements : ${data.warning_count}`);
console.log(` Messages info : ${data.info_count}`);
console.log('\n--- Detail des erreurs ---');
data.errors.forEach(err => console.log(` > ${err}`));
(data.errors || []).forEach(err => console.log(` > ${err}`));
console.log('\n--- Detail des avertissements ---');
data.warnings.forEach(warn => console.log(` > ${warn}`));
(data.warnings || []).forEach(warn => console.log(` > ${warn}`));
console.log('========================================\n');

} catch (error) {
Expand Down
Loading
Loading