2024-10-04 18:43:08 -04:00
|
|
|
const { graphFromList } = require('../graphStuff.js');
|
|
|
|
|
|
|
|
const sqlite = require('better-sqlite3');
|
|
|
|
const db = new sqlite('the_big_db.db', { verbose: console.log });
|
|
|
|
|
|
|
|
const express = require('express');
|
|
|
|
const app = express.Router();
|
|
|
|
|
|
|
|
const page_routes = require('./pages.js');
|
|
|
|
app.use(page_routes);
|
|
|
|
|
|
|
|
const user_routes = require('./users.js');
|
|
|
|
app.use(user_routes);
|
|
|
|
|
|
|
|
app.get('/graph', (req, res) => {
|
|
|
|
try {
|
2024-10-05 12:01:19 -04:00
|
|
|
const rows = db.prepare('select number, html from pages').all();
|
2024-10-04 18:43:08 -04:00
|
|
|
const graph = graphFromList(rows);
|
|
|
|
res.status(200).json(graph);
|
|
|
|
} catch (error) {
|
|
|
|
res.status(500).json({"error": error});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = app;
|