import * as dotenv from 'dotenv';
import express from 'express';
import bodyParser from 'body-parser';
import { addReviewFromRequest } from './borne/post_handler.js';
import { addSocialReviewFromRequest } from './reseaux_sociaux/post_handler.js';
import { startCronJobs } from './stats/update_stats.js';
import * as borneHandler from './borne/get_handler.js';

const app = express();

app.use(bodyParser.urlencoded({extended:true}))
dotenv.config()
app.post('/add_review', (req,res) => addReviewFromRequest(req,res));
app.post('/add_social_review', (req,res) => addSocialReviewFromRequest(req,res));

app.get('/borne/get_last_reviews', borneHandler.handleGetLastReviews);
app.get('/borne/get_review', borneHandler.handleGetReview);
app.get('/borne/get_criteres', borneHandler.handleGetCriteres);
app.get('/borne/notes_autres', borneHandler.handleGetNotesAutres);
app.get('/borne/get_stats', borneHandler.handleGetStats);


startCronJobs();

app.listen(process.env.PORT, () => {
    console.log("Server démaré sur le port " + process.env.PORT)
})

