<Feat> Première version

This commit is contained in:
Valentin Duflot 2026-10-23 12:21:51 +02:00
commit ba9890aad4
24 changed files with 8754 additions and 0 deletions

38
.gitignore vendored Normal file
View file

@ -0,0 +1,38 @@
# Dependencies
node_modules/
.pnpm-store/
# Angular build
dist/
.angular/
coverage/
out-tsc/
# Environment and secrets
.env
.env.*
!.env.example
*.local
# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# IDE / editors
.idea/
.vscode/*
!.vscode/extensions.json
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
# Temporary files
tmp/
temp/
*.tmp

110
EXERCICES_BONUS_DOCKER.md Normal file
View file

@ -0,0 +1,110 @@
# Exercices bonus : Docker
Vous avez réussi à lancer **Le Bouton Rouge** avec Docker Compose ? Voici six défis pour mieux comprendre ce qui se passe derrière l'application.
**Point de départ :** placez-vous dans le dossier racine du projet, celui qui contient `compose.yaml`. Sauf indication contraire, les commandes sont à exécuter depuis ce dossier.
## Exercice 1 : Enquête sur les conteneurs
1. Affichez les conteneurs en cours d'exécution avec `docker compose ps`.
2. Repérez le frontend et le backend. Pour chacun, notez le nom du conteneur, l'image utilisée et les ports affichés.
3. Affichez les journaux de l'application avec `docker compose logs`.
4. Affichez uniquement les journaux du backend avec `docker compose logs backend`.
**Questions :** combien de conteneurs tournent ? Quelle différence voyez-vous entre une *image* et un *conteneur* ?
## Exercice 2 : Saboter puis réparer l'application
1. Ouvrez l'application dans votre navigateur et vérifiez qu'elle fonctionne.
2. Arrêtez uniquement le backend :
```bash
docker compose stop backend
```
3. Actualisez l'application et essayez de vous connecter ou de cliquer sur le bouton si vous êtes déjà connecté.
4. Observez le comportement et, si besoin, les erreurs dans les outils de développement du navigateur (touche `F12`, onglet **Réseau**).
5. Redémarrez le backend avec `docker compose start backend`, puis réessayez.
**Questions :** pourquoi la page peut-elle encore s'afficher alors que certaines actions échouent ? Quel rôle joue chaque conteneur ?
## Exercice 3 : Changer le port d'accès
1. Ouvrez `compose.yaml`.
2. Dans le service `frontend`, remplacez le port publié `8080:80` par `9090:80`.
3. Appliquez la modification :
```bash
docker compose up -d
```
4. Essayez d'accéder à l'application sur `http://localhost:9090`.
5. Vérifiez ce qui se passe sur l'ancienne adresse `http://localhost:8080`.
**Questions :** dans `9090:80`, quel port appartient à votre ordinateur ? Quel port appartient au conteneur ?
## Exercice 4 : Entrer dans un conteneur
1. Ouvrez un terminal **dans** le conteneur backend :
```bash
docker compose exec backend sh
```
2. Affichez le répertoire courant avec `pwd`.
3. Listez les fichiers avec `ls`.
4. Vérifiez la version de Node.js avec `node --version`.
5. Quittez le conteneur avec `exit`.
**Questions :** êtes-vous dans le même environnement que votre ordinateur ? Pourquoi Node.js est-il disponible à l'intérieur du conteneur ?
## Exercice 5 : Modifier le code et reconstruire
1. Dans `backend/server.js`, remplacez le texte de l'un des premiers messages du bouton par une phrase de votre invention.
2. Relancez le service **sans reconstruire son image** :
```bash
docker compose restart backend
```
3. Rechargez l'application et atteignez le clic concerné. Le nouveau message apparaît-il ?
4. Reconstruisez et redémarrez le backend :
```bash
docker compose up -d --build backend
```
5. Rechargez l'application et vérifiez à nouveau le message.
**Questions :** pourquoi un simple redémarrage ne suffit-il pas ? Quelle est la différence entre le code sur votre ordinateur et le code inclus dans une image Docker ?
## Exercice 6 : Masquer le backend à votre ordinateur
1. Dans `compose.yaml`, supprimez **uniquement** la section `ports` du service `backend`. Ne supprimez pas le service lui-même.
2. Appliquez la modification :
```bash
docker compose up -d
```
3. Vérifiez que le frontend reste accessible sur le port choisi à l'exercice 3.
4. Essayez d'accéder directement au backend depuis votre ordinateur avec :
```bash
curl http://localhost:3000/login
```
*Attention : cette commande utilise GET alors que `/login` attend POST. Si vous obtenez une réponse HTTP comme « Cannot GET /login », le backend est joignable. Si la connexion est refusée, il ne l'est pas depuis ce port.*
5. Vérifiez que la connexion depuis l'application Angular fonctionne toujours.
**Questions :** comment le frontend peut-il communiquer avec le backend si le port 3000 n'est plus publié sur votre ordinateur ? À quoi sert le nom de service `backend` dans le réseau Docker Compose ?
---
## Pour terminer
Remettez votre projet dans un état fonctionnel et vérifiez que l'application est accessible dans le navigateur.
**Question de réflexion :** votre application fonctionne maintenant sur votre ordinateur. Que faudrait-il changer pour qu'une personne située dans une autre ville puisse y accéder ?

4
backend/.dockerignore Normal file
View file

@ -0,0 +1,4 @@
node_modules
npm-debug.log
.git
.env

13
backend/Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --omit=dev
COPY server.js ./
EXPOSE 3000
CMD ["node", "server.js"]

863
backend/package-lock.json generated Normal file
View file

@ -0,0 +1,863 @@
{
"name": "le-bouton-rouge-api",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "le-bouton-rouge-api",
"version": "1.0.0",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.2"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.9",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.9.tgz",
"integrity": "sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.16.0",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/cors": {
"version": "2.8.6",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",
"integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==",
"license": "MIT",
"dependencies": {
"object-assign": "^4",
"vary": "^1"
},
"engines": {
"node": ">= 0.10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.3",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.3.tgz",
"integrity": "sha512-Bdcs4+3qlpVlx2NRn6fgX2Ue2/gGRaPeawebgclM0ERSCqDpA+owF1fdPwjJUTAJWMTuAaxjDf+hzb0/4eKvvw==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.5",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.13",
"proxy-addr": "~2.0.7",
"qs": "~6.16.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz",
"integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
"integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/qs": {
"version": "6.16.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz",
"integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==",
"license": "BSD-3-Clause",
"dependencies": {
"es-define-property": "^1.0.1",
"side-channel": "^1.1.1"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
"integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4",
"side-channel-list": "^1.0.1",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}

13
backend/package.json Normal file
View file

@ -0,0 +1,13 @@
{
"name": "le-bouton-rouge-api",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node server.js"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.2"
}
}

78
backend/server.js Normal file
View file

@ -0,0 +1,78 @@
const express = require("express");
const cors = require("cors");
const app = express();
const PORT = process.env.PORT || 3000;
app.use(cors());
app.use(express.json());
app.post("/login", (req, res) => {
const { username, password } = req.body || {};
if (username === "admin" && password === "docker") {
return res.json({
success: true,
message: "Bienvenue. Et surtout, ne touche pas au bouton."
});
}
return res.status(401).json({
success: false,
message: "Identifiants incorrects."
});
});
const messages = [
"Je t'avais pourtant prévenu.",
"Tu as vraiment du mal avec les consignes.",
"Bon. Une fois, ça passe.",
"Tu comptes continuer longtemps ?",
"Ce bouton n'est PAS un jouet.",
"Je commence à perdre patience.",
"Alerte transmise à la NASA.",
"La NASA demande pourquoi tu continues.",
"Un satellite vient de changer d'orbite.",
"Bravo. Tu as réveillé un volcan.",
"Le volcan est très contrarié.",
"Ton adresse IP a été communiquée aux pingouins.",
"Les pingouins préparent leur vengeance.",
"Un technicien vient de démissionner.",
"Deux techniciens supplémentaires ont démissionné.",
"Le serveur commence à transpirer.",
"Température du processeur : 847 °C.",
"Une intelligence artificielle demande l'asile politique.",
"Le ministère des boutons rouges a été prévenu.",
"Tu fais maintenant l'objet d'une enquête.",
"Une commission parlementaire est constituée.",
"Les marchés financiers commencent à paniquer.",
"La Bourse de Tokyo vient de fermer.",
"Internet fonctionne désormais au charbon.",
"Un compte à rebours vient de démarrer.",
"5...",
"4...",
"3...",
"2...",
"BOUM ! 💥 Félicitations. Tu as détruit Internet. Actualise la page pour recommencer."
];
app.post("/click", (req, res) => {
const { count } = req.body || {};
if (!Number.isInteger(count) || count < 1 || count > 30) {
return res.status(400).json({
error: "Le nombre de clics doit être compris entre 1 et 30."
});
}
return res.json({
count,
message: messages[count - 1],
finished: count === 30
});
});
app.listen(PORT, "0.0.0.0", () => {
console.log(`API démarrée sur le port ${PORT}`);
});

34
compose.yaml Normal file
View file

@ -0,0 +1,34 @@
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
ports:
- "____:3000" # 1. Port du backend sur l'hôte
restart: unless-stopped
frontend:
build:
context: ____ # 2. Dossier du frontend
dockerfile: Dockerfile
ports:
- "____:80" # 3. Port du frontend sur l'hôte
depends_on:
- ____ # 4. Service à démarrer avant le frontend
restart: unless-stopped
# 5. Quel nom de service le frontend doit-il utiliser
# pour contacter le backend dans le réseau Docker ?
# Réponse : ____
# 6. Quelle commande démarre les deux services
# en reconstruisant les images ?
# Réponse : ____
# 7. Quelle commande affiche les conteneurs du projet ?
# Réponse : ____
# 8. Quelle commande arrête et supprime les conteneurs
# du projet ?
# Réponse : ____

4
frontend/.dockerignore Normal file
View file

@ -0,0 +1,4 @@
node_modules
dist
.angular
.git

11
frontend/Dockerfile Normal file
View file

@ -0,0 +1,11 @@
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist/le-bouton-rouge-frontend/browser /usr/share/nginx/html
EXPOSE 80

22
frontend/README.md Normal file
View file

@ -0,0 +1,22 @@
# Le bouton rouge — Frontend Angular
Application Angular standalone destinée au TP Docker. Backend Express attendu : `POST /login` et `POST /click`.
## Lancement en local
Démarrer le backend Express sur `http://localhost:3000`, puis :
```bash
npm install
npm start
```
Ouvrir `http://localhost:4200`. Le proxy Angular redirige `/api/login` vers `http://localhost:3000/login` et `/api/click` vers `http://localhost:3000/click`.
Identifiants de démonstration : `admin` / `docker`.
## Docker
Le Dockerfile est fourni. Pour le faire fonctionner dans Docker Compose, nommer le service backend **`backend`** et exposer le frontend sur le port **80** du conteneur (par exemple `8080:80`). Nginx relaie les appels `/api/` vers `http://backend:3000/`.
Le frontend n'inclut pas le backend. Le compteur est conservé en mémoire côté navigateur et réinitialisé par « Recommencer ».

20
frontend/angular.json Normal file
View file

@ -0,0 +1,20 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"le-bouton-rouge-frontend": {
"projectType": "application",
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {"builder": "@angular/build:application", "options": {"outputPath": "dist/le-bouton-rouge-frontend", "index": "src/index.html", "browser": "src/main.ts", "tsConfig": "tsconfig.app.json", "styles": ["src/styles.scss"]}},
"serve": {"builder": "@angular/build:dev-server", "options": {"buildTarget": "le-bouton-rouge-frontend:build", "proxyConfig": "proxy.conf.json"}}
}
}
},
"cli": {
"analytics": false
}
}

15
frontend/nginx.conf Normal file
View file

@ -0,0 +1,15 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location /api/ {
proxy_pass http://backend:3000/;
proxy_set_header Host $host;
}
location / {
try_files $uri $uri/ /index.html;
}
}

7403
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

8
frontend/package.json Normal file
View file

@ -0,0 +1,8 @@
{
"name": "le-bouton-rouge-frontend",
"version": "1.0.0",
"private": true,
"scripts": {"start": "ng serve --host 0.0.0.0", "build": "ng build"},
"dependencies": {"@angular/common": "^20.3.0", "@angular/compiler": "^20.3.0", "@angular/core": "^20.3.0", "@angular/forms": "^20.3.0", "@angular/platform-browser": "^20.3.0", "rxjs": "~7.8.2", "tslib": "^2.8.1", "zone.js": "~0.15.1"},
"devDependencies": {"@angular/build": "^20.3.0", "@angular/cli": "^20.3.0", "@angular/compiler-cli": "^20.3.0", "typescript": "~5.9.2"}
}

1
frontend/proxy.conf.json Normal file
View file

@ -0,0 +1 @@
{"/api":{"target":"http://localhost:3000","secure":false,"changeOrigin":true,"pathRewrite":{"^/api":""}}}

View file

@ -0,0 +1,36 @@
<main class="page">
<div class="glow glow-one"></div><div class="glow glow-two"></div>
<header class="topbar"><span class="logo-mark">●</span> PROJET <strong>BOUTON ROUGE</strong><span class="top-status"><span class="dot"></span> SYSTÈME OPÉRATIONNEL</span></header>
@if (!loggedIn()) {
<section class="panel login-panel">
<div class="eyebrow">ACCÈS RESTREINT // 001</div>
<div class="lock">⌁</div>
<h1>Zone interdite<span class="accent">.</span></h1>
<p>Identifie-toi pour accéder à une expérience que personne n'a demandée.</p>
<form (ngSubmit)="login()">
<label for="username">IDENTIFIANT</label>
<input id="username" name="username" [(ngModel)]="username" autocomplete="username" placeholder="Identifiant" required>
<label for="password">MOT DE PASSE</label>
<input id="password" name="password" [(ngModel)]="password" type="password" autocomplete="current-password" placeholder="Mot de passe" required>
<button class="login-button" type="submit" [disabled]="loading()">{{ loading() ? 'CONNEXION…' : 'ENTRER →' }}</button>
</form>
@if (error()) { <p class="error" role="alert">{{ error() }}</p> }
<div class="footnote">ATTENTION : CETTE APPLICATION NE SERT STRICTEMENT À RIEN.</div>
</section>
} @else {
<section class="game">
<div class="eyebrow">PROTOCOLE EXPÉRIMENTAL // 002</div>
<h1>{{ finished() ? 'C’est trop tard.' : 'Ne touche pas.' }}</h1>
<p class="subtitle">{{ finished() ? 'On t’avait prévenu.' : 'Vraiment. Il y a d’autres choses à faire.' }}</p>
<div class="button-area" [class.finished]="finished()">
<div class="ring ring-one"></div><div class="ring ring-two"></div>
<button class="red-button" (click)="clickButton()" [disabled]="loading() || finished()" aria-label="Ne pas appuyer sur le bouton rouge"><span>{{ finished() ? '💥' : 'NE PAS' }}<br>{{ finished() ? '' : 'APPUYER' }}</span></button>
</div>
<div class="message-panel" aria-live="polite"><span class="message-label">MESSAGE DU SYSTÈME</span><p>{{ message() }}</p></div>
<div class="progress"><div class="progress-info"><span>INDICE DE CATASTROPHE</span><strong>{{ count() }} / 30</strong></div><div class="track"><div class="fill" [style.width.%]="count() / 30 * 100"></div></div></div>
@if (error()) { <p class="error" role="alert">{{ error() }}</p> }
@if (finished()) { <button class="reset-button" (click)="restart()">↻ RECOMMENCER</button> }
</section>
}
<footer>UNE EXPÉRIENCE INUTILE · PROPULSÉE PAR ANGULAR + EXPRESS</footer>
</main>

View file

@ -0,0 +1 @@
:host{display:block;min-height:100vh}.page{position:relative;isolation:isolate;min-height:100vh;overflow:hidden;display:flex;flex-direction:column;align-items:center;padding:0 24px;background:radial-gradient(ellipse at 50% 45%,#201823 0%,#101019 62%)}.glow{position:absolute;z-index:-1;width:460px;height:460px;border-radius:50%;filter:blur(105px);opacity:.17;pointer-events:none}.glow-one{background:#d52d43;top:15%;left:-260px}.glow-two{background:#7e446d;right:-280px;bottom:8%}.topbar{width:min(100%,1100px);height:90px;display:flex;align-items:center;gap:8px;font:700 11px 'Space Mono',monospace;letter-spacing:1.6px;color:#8e8996}.topbar strong{color:#f7f5f7}.logo-mark{color:#f04d5b;font-size:24px;margin-right:8px}.top-status{margin-left:auto;font-size:10px;color:#85818d}.dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:#59d9a5;margin-right:6px;box-shadow:0 0 12px #59d9a5}.panel{background:#1c1b27;border:1px solid #373140;border-radius:20px;box-shadow:0 25px 100px #0005}.login-panel{width:min(100%,440px);margin:auto;padding:40px}.eyebrow{font:700 11px 'Space Mono',monospace;color:#ed6471;letter-spacing:2px}.lock{font-size:45px;color:#ed6471;margin-top:24px}h1{font-size:clamp(38px,6vw,60px);line-height:1.06;letter-spacing:-2px;margin:18px 0 12px;font-weight:800}.login-panel h1{font-size:42px}.accent{color:#ed5262}.login-panel>p,.subtitle{color:#9e98a7;line-height:1.65;font-size:14px}.login-panel form{display:flex;flex-direction:column;margin-top:30px;gap:11px}.login-panel label{font:700 10px 'Space Mono',monospace;color:#9e98a7;letter-spacing:1.4px;margin-top:9px}.login-panel input{width:100%;background:#12121c;border:1px solid #403a49;border-radius:9px;color:white;padding:15px 16px;outline:none}.login-panel input:focus{border-color:#ef5565}.login-button{margin-top:15px;border:0;border-radius:9px;background:#e94d5d;color:white;font:700 12px 'Space Mono',monospace;letter-spacing:1px;padding:17px}.login-button:hover{background:#f46673}.footnote{border-top:1px solid #37313e;margin-top:30px;padding-top:22px;font:10px 'Space Mono',monospace;line-height:1.7;color:#746f7e;text-align:center}.game{width:min(100%,650px);margin:auto;text-align:center;padding:30px 0 20px}.game h1{margin-top:22px}.subtitle{margin:0}.button-area{position:relative;height:330px;display:flex;justify-content:center;align-items:center}.ring{position:absolute;border:1px solid #4b2a36;border-radius:50%;pointer-events:none}.ring-one{width:275px;height:275px}.ring-two{width:325px;height:325px;border-color:#332634}.red-button{position:relative;z-index:1;width:222px;height:222px;border-radius:50%;border:11px solid #9e2437;background:radial-gradient(circle at 35% 25%,#ff6976 0%,#ed364d 35%,#b70e2c 85%);box-shadow:0 13px 0 #701528,0 21px 30px #0009,0 0 70px #db28463b,inset 0 5px 15px #ffb2b466;color:white;font:800 22px 'Space Mono',monospace;letter-spacing:1px;text-shadow:0 2px 3px #69091d;transition:transform .12s,box-shadow .12s}.red-button:not(:disabled):active{transform:translateY(10px);box-shadow:0 3px 0 #701528,0 7px 15px #0009}.finished .red-button{filter:grayscale(.4)}.message-panel{background:#1d1c28;border:1px solid #3a3340;border-radius:13px;min-height:110px;padding:22px}.message-label{font:700 10px 'Space Mono',monospace;letter-spacing:2px;color:#807a8d}.message-panel p{font-size:19px;font-weight:700;margin:13px 0 0;line-height:1.4}.progress{margin:24px 0}.progress-info{display:flex;justify-content:space-between;color:#8e8797;font:10px 'Space Mono',monospace;letter-spacing:1px}.progress-info strong{color:#ed6471}.track{height:6px;border-radius:8px;background:#35303d;margin-top:12px;overflow:hidden}.fill{height:100%;background:linear-gradient(90deg,#d72d47,#ff7783);transition:width .25s}.error{color:#ff8996;font-size:13px}.reset-button{border:1px solid #6c4752;border-radius:9px;padding:12px 22px;color:white;background:#2b202e;font:700 12px 'Space Mono',monospace}footer{padding:24px 0;color:#686373;text-align:center;font:10px 'Space Mono',monospace;letter-spacing:1px}@media(max-width:550px){.topbar{height:72px;font-size:9px}.top-status{display:none}.login-panel{padding:28px}.game h1{font-size:44px}.button-area{height:285px}.ring-one{width:250px;height:250px}.ring-two{width:285px;height:285px}.red-button{width:200px;height:200px}}

View file

@ -0,0 +1,68 @@
import { Component, inject, signal } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
interface LoginResponse { success: boolean; message: string; }
interface ClickResponse { count: number; message: string; finished: boolean; }
@Component({
selector: 'app-root',
standalone: true,
imports: [FormsModule],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
private readonly http = inject(HttpClient);
readonly loggedIn = signal(false);
readonly loading = signal(false);
readonly count = signal(0);
readonly finished = signal(false);
readonly message = signal('Un bouton. Une seule règle. Ne pas appuyer.');
readonly error = signal('');
username = '';
password = '';
login(): void {
if (this.loading()) return;
this.error.set('');
this.loading.set(true);
this.http.post<LoginResponse>('/api/login', { username: this.username, password: this.password })
.subscribe({
next: response => {
this.loading.set(false);
if (response.success) this.loggedIn.set(true);
},
error: () => {
this.loading.set(false);
this.error.set('Connexion refusée. Vérifie tes identifiants et le serveur Express.');
}
});
}
clickButton(): void {
if (this.loading() || this.finished()) return;
this.loading.set(true);
this.error.set('');
const nextCount = this.count() + 1;
this.http.post<ClickResponse>('/api/click', { count: nextCount }).subscribe({
next: response => {
this.count.set(response.count);
this.message.set(response.message);
this.finished.set(response.finished);
this.loading.set(false);
},
error: () => {
this.error.set('Le serveur ne répond plus. Le bouton a-t-il gagné ?');
this.loading.set(false);
}
});
}
restart(): void {
this.count.set(0);
this.finished.set(false);
this.message.set('Un bouton. Une seule règle. Ne pas appuyer.');
this.error.set('');
}
}

1
frontend/src/index.html Normal file
View file

@ -0,0 +1 @@
<!doctype html><html lang="fr"><head><meta charset="utf-8"><title>NE PAS APPUYER — Le bouton rouge</title><base href="/"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="theme-color" content="#101019"></head><body><app-root></app-root></body></html>

7
frontend/src/main.ts Normal file
View file

@ -0,0 +1,7 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { provideHttpClient } from '@angular/common/http';
import { AppComponent } from './app/app.component';
import 'zone.js';
bootstrapApplication(AppComponent, { providers: [provideHttpClient()] })
.catch(error => console.error(error));

2
frontend/src/styles.scss Normal file
View file

@ -0,0 +1,2 @@
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap');
*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#101019;color:#f4f1f1;font-family:'DM Sans',Arial,sans-serif}button,input{font:inherit}button{cursor:pointer}button:disabled{cursor:not-allowed;opacity:.65}

View file

@ -0,0 +1 @@
{"extends":"./tsconfig.json","compilerOptions":{"outDir":"./out-tsc/app","types":[]},"files":["src/main.ts"],"include":["src/**/*.d.ts"]}

1
frontend/tsconfig.json Normal file
View file

@ -0,0 +1 @@
{"compileOnSave":false,"compilerOptions":{"outDir":"./dist/out-tsc","strict":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"skipLibCheck":true,"esModuleInterop":true,"sourceMap":true,"declaration":false,"experimentalDecorators":true,"moduleResolution":"bundler","importHelpers":true,"target":"ES2022","module":"ES2022","lib":["ES2022","dom"]},"angularCompilerOptions":{"strictInjectionParameters":true,"strictInputAccessModifiers":true,"strictTemplates":true}}