feat: add Next.js configuration and automated super admin initialization scripts
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
output: 'standalone',
|
// output: 'standalone',
|
||||||
allowedDevOrigins: ['10.0.2.2'],
|
allowedDevOrigins: ['10.0.2.2'],
|
||||||
|
|
||||||
// 1. On ignore les erreurs de type et ESLint pour que le build
|
// 1. On ignore les erreurs de type et ESLint pour que le build
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ if (fs.existsSync(rootScript)) {
|
|||||||
|
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
async function waitForDatabase(prismaClient, maxRetries = 30, delayMs = 2000) {
|
const MAX_RETRIES = parseInt(process.env.DB_WAIT_MAX_RETRIES || '90', 10);
|
||||||
|
const DELAY_MS = parseInt(process.env.DB_WAIT_DELAY_MS || '2000', 10);
|
||||||
|
|
||||||
|
async function waitForDatabase(prismaClient, maxRetries = MAX_RETRIES, delayMs = DELAY_MS) {
|
||||||
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
try {
|
try {
|
||||||
await prismaClient.$executeRawUnsafe('SELECT 1;');
|
await prismaClient.$executeRawUnsafe('SELECT 1;');
|
||||||
@@ -21,11 +24,19 @@ if (fs.existsSync(rootScript)) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = err.message || '';
|
const msg = err.message || '';
|
||||||
const isStartingUp = msg.includes('the database system is starting up') ||
|
const isStartingUp = msg.includes('the database system is starting up') ||
|
||||||
msg.includes('57P03') ||
|
msg.includes('57P03');
|
||||||
msg.includes('ConnectionRefused') ||
|
const isUnreachable = msg.includes('ConnectionRefused') ||
|
||||||
msg.includes("Can't reach database server");
|
msg.includes("Can't reach database server") ||
|
||||||
|
msg.includes('connection refused') ||
|
||||||
|
msg.includes('P1001');
|
||||||
|
|
||||||
|
let info = msg.split('\n')[0].substring(0, 80);
|
||||||
|
if (isStartingUp) {
|
||||||
|
info = 'PostgreSQL est en cours de démarrage (recovery/init)...';
|
||||||
|
} else if (isUnreachable) {
|
||||||
|
info = 'PostgreSQL pas encore joignable (démarrage du conteneur en cours)...';
|
||||||
|
}
|
||||||
|
|
||||||
const info = isStartingUp ? 'PostgreSQL est en cours de démarrage...' : msg.split('\n')[0].substring(0, 80);
|
|
||||||
console.log(`⏳ En attente de la base de données (${attempt}/${maxRetries}) : ${info}`);
|
console.log(`⏳ En attente de la base de données (${attempt}/${maxRetries}) : ${info}`);
|
||||||
|
|
||||||
if (attempt === maxRetries) {
|
if (attempt === maxRetries) {
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ const bcrypt = require('bcryptjs');
|
|||||||
|
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
async function waitForDatabase(prismaClient, maxRetries = 30, delayMs = 2000) {
|
const MAX_RETRIES = parseInt(process.env.DB_WAIT_MAX_RETRIES || '90', 10);
|
||||||
|
const DELAY_MS = parseInt(process.env.DB_WAIT_DELAY_MS || '2000', 10);
|
||||||
|
|
||||||
|
async function waitForDatabase(prismaClient, maxRetries = MAX_RETRIES, delayMs = DELAY_MS) {
|
||||||
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
try {
|
try {
|
||||||
await prismaClient.$executeRawUnsafe('SELECT 1;');
|
await prismaClient.$executeRawUnsafe('SELECT 1;');
|
||||||
@@ -12,11 +15,19 @@ async function waitForDatabase(prismaClient, maxRetries = 30, delayMs = 2000) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = err.message || '';
|
const msg = err.message || '';
|
||||||
const isStartingUp = msg.includes('the database system is starting up') ||
|
const isStartingUp = msg.includes('the database system is starting up') ||
|
||||||
msg.includes('57P03') ||
|
msg.includes('57P03');
|
||||||
msg.includes('ConnectionRefused') ||
|
const isUnreachable = msg.includes('ConnectionRefused') ||
|
||||||
msg.includes("Can't reach database server");
|
msg.includes("Can't reach database server") ||
|
||||||
|
msg.includes('connection refused') ||
|
||||||
|
msg.includes('P1001');
|
||||||
|
|
||||||
|
let info = msg.split('\n')[0].substring(0, 80);
|
||||||
|
if (isStartingUp) {
|
||||||
|
info = 'PostgreSQL est en cours de démarrage (recovery/init)...';
|
||||||
|
} else if (isUnreachable) {
|
||||||
|
info = 'PostgreSQL pas encore joignable (démarrage du conteneur en cours)...';
|
||||||
|
}
|
||||||
|
|
||||||
const info = isStartingUp ? 'PostgreSQL est en cours de démarrage...' : msg.split('\n')[0].substring(0, 80);
|
|
||||||
console.log(`⏳ En attente de la base de données (${attempt}/${maxRetries}) : ${info}`);
|
console.log(`⏳ En attente de la base de données (${attempt}/${maxRetries}) : ${info}`);
|
||||||
|
|
||||||
if (attempt === maxRetries) {
|
if (attempt === maxRetries) {
|
||||||
|
|||||||
Reference in New Issue
Block a user