import express from "express";
import path from "path";

const app = express();

app.use('/public', express.static('public'))

app.get('/data.json', async (req, res) => {
    res.json({
        coms: await Bun.file('./_COMMUNES.geojson').json(),
        arrs: await Bun.file('./_ARRONDISSEMENTS.geojson').json(),
        deps: await Bun.file('./_DEPARTEMENTS.geojson').json(),
    });
})

app.get('/map', (req, res) => {
    res.sendFile( path.resolve(__dirname, 'map.html') )
})

app.get('/', (req, res) => {
    res.sendFile( path.resolve(__dirname, 'index.html') )
})

app.listen(8080, '0.0.0.0');