Skip to content
Snippets Groups Projects
server.js 595 B
Newer Older
  • Learn to ignore specific revisions
  • Bastien's avatar
    Bastien committed
    const express = require('express')
    const app = express()
    const port = 3000
    
    var cors = require('cors');
    var session = require('express-session');
    const crypto = require('node:crypto');
    
    Bastien's avatar
    Bastien committed
    
    
    app.use(express.json());
    
    app.use(session({
      secret:crypto.randomUUID(),
      resave:false,
      saveUninitialized:false
    }));
    app.use(express.urlencoded({ extended: true }));
    app.use(cors({origin: 'http://localhost:5173', credentials : true}));
    
    Bastien's avatar
    Bastien committed
    const userRoutes = require('./routes/user');
    app.use('/user', userRoutes);
    
    app.listen(port, () => {
      console.log(`Serveur en cours d'exécution sur le port ${port}`)
    })