1
0

coreection chargement js server.js

This commit is contained in:
unfr 2025-08-10 11:49:16 +02:00
parent abc64501e2
commit c6c92bf1ef
2 changed files with 26 additions and 6 deletions

View File

@ -9,6 +9,7 @@ const os = require('os');
const config = require('./config'); const config = require('./config');
const db = require('./db'); const db = require('./db');
db.testConnection(); // vérification au démarrage db.testConnection(); // vérification au démarrage
const app = express(); const app = express();
@ -27,8 +28,14 @@ app.use(express.static('public'));
const autopostRouter = express.Router(); const autopostRouter = express.Router();
autopostRouter.use('/js', express.static(path.join(__dirname, '../node_modules/@tailwindcss/browser/dist'))); app.use('/js', express.static(
autopostRouter.use('/jquery', express.static(path.join(__dirname, '../node_modules/jquery/dist'))); path.join(__dirname, '../node_modules/@tailwindcss/browser/dist'),
{ setHeaders: (res) => res.type('application/javascript') } // optionnel
));
app.use('/jquery', express.static(
path.join(__dirname, '../node_modules/jquery/dist'),
{ setHeaders: (res) => res.type('application/javascript') } // optionnel
));
// --------------------------- Auth non protégée ----------------------------- // --------------------------- Auth non protégée -----------------------------
autopostRouter.get('/login', (req, res) => { autopostRouter.get('/login', (req, res) => {
@ -39,7 +46,7 @@ autopostRouter.get('/login', (req, res) => {
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Login</title> <title>Login</title>
<!-- Inclusion de Tailwind CSS via le CDN --> <!-- Inclusion de Tailwind CSS via le CDN -->
<script src="js/index.global.js"></script> <script src="/js/index.global.js"></script>
</head> </head>
<body class="bg-slate-900 flex items-center justify-center min-h-screen"> <body class="bg-slate-900 flex items-center justify-center min-h-screen">
<div class="bg-slate-700 p-8 rounded-lg shadow-md w-80"> <div class="bg-slate-700 p-8 rounded-lg shadow-md w-80">
@ -69,6 +76,7 @@ autopostRouter.post('/login', (req, res) => {
res.send('Identifiants invalides. <a href="/autopost/login">Réessayer</a>'); res.send('Identifiants invalides. <a href="/autopost/login">Réessayer</a>');
} }
}); });
autopostRouter.get('/logout', (req, res) => { autopostRouter.get('/logout', (req, res) => {
req.session.destroy(); req.session.destroy();
res.redirect('/autopost/login'); res.redirect('/autopost/login');
@ -106,8 +114,8 @@ autopostRouter.get('/', async (req, res) => {
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Suivi Autopost</title> <title>Suivi Autopost</title>
<script src="js/index.global.js"></script> <script src="/js/index.global.js"></script>
<script src="jquery/jquery.min.js"></script> <script src="/jquery/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet">
</head> </head>
<body class="bg-slate-900 text-white font-sans p-4"> <body class="bg-slate-900 text-white font-sans p-4">
@ -171,6 +179,10 @@ autopostRouter.get('/', async (req, res) => {
statusText = 'DEJA DISPONIBLE'; statusText = 'DEJA DISPONIBLE';
statusClass = 'bg-pink-300 text-black font-bold'; statusClass = 'bg-pink-300 text-black font-bold';
break; break;
case 4:
statusText = 'EN COURS';
statusClass = 'bg-yellow-300 text-black font-bold';
break;
default: default:
statusText = 'INCONNU'; statusText = 'INCONNU';
} }
@ -269,6 +281,10 @@ autopostRouter.get('/', async (req, res) => {
statusText = 'DEJA DISPONIBLE'; statusText = 'DEJA DISPONIBLE';
statusClass = 'bg-pink-300 text-black font-bold'; statusClass = 'bg-pink-300 text-black font-bold';
break; break;
case 4:
statusText = 'EN COURS';
statusClass = 'bg-yellow-300 text-black font-bold';
break;
default: default:
statusText = 'INCONNU'; statusText = 'INCONNU';
} }
@ -420,6 +436,10 @@ autopostRouter.get('/', async (req, res) => {
statusText = 'DEJA DISPONIBLE'; statusText = 'DEJA DISPONIBLE';
statusClass = 'bg-pink-300 text-black font-bold'; statusClass = 'bg-pink-300 text-black font-bold';
break; break;
case 4:
statusText = 'EN COURS';
statusClass = 'bg-yellow-300 text-black font-bold';
break;
default: default:
statusText = 'INCONNU'; statusText = 'INCONNU';
} }