/ index.js
index.js
1 const express = require('express'); 2 const session = require('express-session'); 3 const path = require('path'); 4 5 const captchaRoutes = require('./routes/captcha'); 6 const authRoutes = require('./routes/auth'); 7 const profileRoutes = require('./routes/profile'); 8 9 const app = express(); 10 const serverPort = 3131; 11 12 app.use(express.json()); 13 14 app.use(session({ 15 secret: 'captchaSecretKey', 16 resave: false, 17 saveUninitialized: true, 18 cookie: { secure: false }, 19 })); 20 21 app.use(express.static(path.join(__dirname, 'public'))); 22 23 app.use(captchaRoutes); 24 app.use(authRoutes); 25 app.use(profileRoutes); 26 27 app.get('/', (req, res) => { 28 res.sendFile(path.join(__dirname, 'public', 'index.html')); 29 }); 30 31 app.listen(serverPort, () => { 32 console.log(`Server started on http://localhost:${serverPort}`); 33 });