SecondChance est une application web permettant de publier et rechercher des objets d’occasion (meubles, matériel, etc.).
- Backend: Node.js/Express + MongoDB
- Frontend: React (create‑react‑app)
- Journalisation: Pino
- Authentification: JWT
- Import initial des données: seed automatique au démarrage du backend
secondChance-backend/: API REST (Express) + import Mongo initial + ressources statiquessecondChance-frontend/: SPA React (pages: accueil, items, détail, login/register, profil)sentiment/: micro‑service Node d’analyse de sentiment (facultatif pour ce projet principal)
- Node.js 18+
- MongoDB accessible via une URI (cloud ou locale)
- npm 8+
Créer un fichier .env dans secondChance-backend/ avec au minimum:
MONGO_URL=<votre_uri_mongodb>
JWT_SECRET=<votre_secret_jwt>
PORT=3060
Notes:
- Le backend écoute par défaut sur le port 3060.
- L’import initial appelle automatiquement
loadData(): si la collection est vide, les items de démonstration sont insérés.
- Backend
cd secondChance-backend
npm install
node app.js
Le serveur démarre sur http://localhost:3060.
- Frontend
cd secondChance-frontend
npm install
npm start
L’UI démarre sur http://localhost:3000 et consomme l’API du backend.
Base URL par défaut: http://localhost:3060
-
Authentification (
/api/auth)- POST
/register– inscription- body:
{ email, firstName, lastName, password } - réponse:
{ authtoken, email }
- body:
- POST
/login– connexion- body:
{ email, password } - réponse:
{ authtoken, userName, userEmail }
- body:
- PUT
/update– mise à jour du profil- headers:
email: <email_utilisateur> - body:
{ name }(met à jourfirstName)
- headers:
- POST
-
Items (
/api/secondchance/items)- GET
/– liste des items - GET
/:id– détail d’un item parid - POST
/– création d’un item (multipart/form‑data avec image)- form‑data:
file(image), autres champs de l’item - Remarques: taille max 5MB, images uniquement; champ enregistré sous
imagePath
- form‑data:
- PUT
/:id– mise à jour d’un item - DELETE
/:id– suppression d’un item
- GET
-
Recherche (
/api/secondchance/search)- Voir
secondChance-backend/routes/searchRoutes.js
- Voir
- Register
curl -X POST http://localhost:3060/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","firstName":"Jane","lastName":"Doe","password":"Passw0rd!"}'
- Login
curl -X POST http://localhost:3060/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"Passw0rd!"}'
- Créer un item avec image
curl -X POST http://localhost:3060/api/secondchance/items \
-H "Accept: application/json" \
-F file=@./path/to/image.jpg \
-F name="Bureau" -F description="Bureau en bon état"
- Suivre les etapes du fichier IBM_Cloud_Deployment_Guide.md
- Logs: Pino est utilisé (middleware
pino-http+ logger applicatif) - Statics:
secondChance-backend/public/est servi par Express (/public) - Upload d’images: stockées dans
secondChance-backend/public/images
Voir LICENSE.