Merge remote-tracking branch 'origin/main' into Emmanuel
Intègre la chaîne CI/CD et la dockerisation venues de main. Conflits sur backend/package-lock.json et frontend/package-lock.json : résolus en régénérant les deux lockfiles depuis les package.json fusionnés, qui réunissent les dépendances des deux branches (helmet, express-rate-limit, passport, passport-google-oauth20 côté Emmanuel ; jest-junit côté main). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
7
backend/.dockerignore
Normal file
7
backend/.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
||||
node_modules
|
||||
npm-debug.log
|
||||
.env
|
||||
coverage
|
||||
.git
|
||||
.gitignore
|
||||
README.md
|
||||
15
backend/Dockerfile
Normal file
15
backend/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY prisma ./prisma
|
||||
RUN npx prisma generate
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["npm", "start"]
|
||||
@@ -1,26 +1,33 @@
|
||||
module.exports = {
|
||||
testEnvironment: "node",
|
||||
|
||||
// Dossier des tests
|
||||
testMatch: ["**/tests/**/*.test.js"],
|
||||
|
||||
// Nettoyage des mocks entre les tests
|
||||
clearMocks: true,
|
||||
|
||||
// Timeout (utile pour Prisma / DB)
|
||||
testTimeout: 10000,
|
||||
|
||||
// Affichage des logs de test
|
||||
verbose: true,
|
||||
verbose: true,
|
||||
|
||||
// Couverture de code (optionnel mais bon pour soutenance)
|
||||
collectCoverage: true,
|
||||
coverageDirectory: "coverage",
|
||||
|
||||
coverageReporters: [
|
||||
"text",
|
||||
"lcov",
|
||||
"html"
|
||||
],
|
||||
|
||||
// Fichiers à ignorer
|
||||
testPathIgnorePatterns: ["/node_modules/"],
|
||||
reporters: [
|
||||
"default",
|
||||
[
|
||||
"jest-junit",
|
||||
{
|
||||
outputDirectory: "./test-results",
|
||||
outputName: "junit.xml"
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
// Configuration pour Jest avec Supertest
|
||||
//setupFilesAfterEnv: ["<rootDir>/tests/setup.js"]
|
||||
};
|
||||
testPathIgnorePatterns: ["/node_modules/"]
|
||||
};
|
||||
|
||||
75
backend/package-lock.json
generated
75
backend/package-lock.json
generated
@@ -29,6 +29,7 @@
|
||||
"cross-env": "^10.1.0",
|
||||
"dotenv": "^17.4.2",
|
||||
"jest": "^30.4.2",
|
||||
"jest-junit": "^17.0.0",
|
||||
"nodemon": "^3.1.14",
|
||||
"supertest": "^7.2.2"
|
||||
}
|
||||
@@ -609,9 +610,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@emnapi/wasi-threads": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz",
|
||||
"integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==",
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz",
|
||||
"integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
@@ -3201,9 +3202,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/express-rate-limit": {
|
||||
"version": "8.6.1",
|
||||
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.6.1.tgz",
|
||||
"integrity": "sha512-0D493aP61w0TJ2A0wy27riRsO7FMQ7FK+KUHOKCSfPvYo0R55aiC6emCVgFUeShH0fq0ICPVzNcgoS+BsbXQCA==",
|
||||
"version": "8.6.2",
|
||||
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.6.2.tgz",
|
||||
"integrity": "sha512-YH4ru+eOJxQABscKFfRCy9R7x9QFGdezclVMwwgFFndzS2Xnm0uo6B0ABZsLhcpeptGv2qvuJVWlQr9gQZoC3A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.4.3",
|
||||
@@ -3788,9 +3789,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ip-address": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.4.0.tgz",
|
||||
"integrity": "sha512-oSK96Grm3aP6OrS263xVxbNDGVL7rzBtYdpGqlDG8iQdoenDoTs/nkki+DflYbAEE8Xl6o5YxhxlrKvI3nqKXQ==",
|
||||
"version": "10.5.0",
|
||||
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.5.0.tgz",
|
||||
"integrity": "sha512-R5SnVLJmgYYvf2F2ZgwSBnelz5G4q5AxIC277GDfUaNbrZKNANcBC7RHqYYePlszf4kBolVkJauG0ZjHHFh55g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 12"
|
||||
@@ -4488,6 +4489,22 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-junit": {
|
||||
"version": "17.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-17.0.0.tgz",
|
||||
"integrity": "sha512-RYWCkq4j59gUXj5DsgbIE7xFBZzu1gtibPhyjSjMmGaOTLnqlXhg7x9zuGCwgbCuMAyoyvk0Mi8wSrRR5uOeLA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"mkdirp": "^1.0.4",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"uuid": "^14.0.0",
|
||||
"xml": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-leak-detector": {
|
||||
"version": "30.4.1",
|
||||
"resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-30.4.1.tgz",
|
||||
@@ -5406,6 +5423,19 @@
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/mkdirp": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mkdirp": "bin/cmd.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
@@ -5488,9 +5518,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/nodemailer": {
|
||||
"version": "9.0.3",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-9.0.3.tgz",
|
||||
"integrity": "sha512-n+YP+NKwR5zRWa60k3GiQ6Q3B4KXCoAw40dAKeCtYn020iNN74aWK2liXIC3ZEATeGql7we3tE3t8QwhY0eskw==",
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-9.0.5.tgz",
|
||||
"integrity": "sha512-wvjiKvjczmsN7U/8006JOdXubgBk2XFAbioDMbT+sM7cPs0QrhJTa6KBRX7P5REGGkDcLUz/EarWidb8G8C1jQ==",
|
||||
"license": "MIT-0",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
@@ -6952,6 +6982,20 @@
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "14.0.1",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.1.tgz",
|
||||
"integrity": "sha512-6ZxzVpzDXDa3bJWaHilVayA+BH/1zmxCJoVgvmqJnid/gPoKHxUrS/aC/T6LGQtNHT+XHG9fXPJB4d+IrU30Ew==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "dist-node/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/v8-to-istanbul": {
|
||||
"version": "9.3.0",
|
||||
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz",
|
||||
@@ -7058,6 +7102,13 @@
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/xml": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
|
||||
"integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/y18n": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
"generate:tickets": "node src/scripts/generateTickets.js",
|
||||
"test": "jest --runInBand",
|
||||
"test:watch": "jest --watch",
|
||||
"test:coverage": "jest --coverage"
|
||||
"test:coverage": "jest --coverage",
|
||||
"init:db": "node src/scripts/initDatabase.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
@@ -35,6 +36,7 @@
|
||||
"cross-env": "^10.1.0",
|
||||
"dotenv": "^17.4.2",
|
||||
"jest": "^30.4.2",
|
||||
"jest-junit": "^17.0.0",
|
||||
"nodemon": "^3.1.14",
|
||||
"supertest": "^7.2.2"
|
||||
},
|
||||
|
||||
55
backend/src/scripts/initDatabase.js
Normal file
55
backend/src/scripts/initDatabase.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const { execSync } = require("child_process");
|
||||
const prisma = require("../config/prisma");
|
||||
|
||||
async function main() {
|
||||
let lotCount = await prisma.lot.count();
|
||||
let ticketCount = await prisma.ticket.count();
|
||||
|
||||
console.log(`Lots présents : ${lotCount}`);
|
||||
console.log(`Tickets présents : ${ticketCount}`);
|
||||
|
||||
if (lotCount === 0) {
|
||||
console.log("Aucun lot trouvé : exécution du seed...");
|
||||
execSync("npx prisma db seed", {
|
||||
stdio: "inherit",
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
lotCount = await prisma.lot.count();
|
||||
console.log(`Lots présents après seed : ${lotCount}`);
|
||||
} else {
|
||||
console.log("Les lots existent déjà : seed ignoré.");
|
||||
}
|
||||
|
||||
if (lotCount !== 5) {
|
||||
throw new Error(
|
||||
`Initialisation interrompue : 5 lots attendus, ${lotCount} trouvé(s).`
|
||||
);
|
||||
}
|
||||
|
||||
ticketCount = await prisma.ticket.count();
|
||||
|
||||
if (ticketCount === 0) {
|
||||
console.log("Aucun ticket trouvé : génération des tickets...");
|
||||
execSync("npm run generate:tickets", {
|
||||
stdio: "inherit",
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
ticketCount = await prisma.ticket.count();
|
||||
console.log(`Tickets présents après génération : ${ticketCount}`);
|
||||
} else {
|
||||
console.log("Les tickets existent déjà : génération ignorée.");
|
||||
}
|
||||
|
||||
console.log("Initialisation de la base terminée.");
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((error) => {
|
||||
console.error("Erreur pendant l'initialisation de la base :", error);
|
||||
process.exitCode = 1;
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user