import express from 'express'; import * as core from "express-serve-static-core"; import mysql from "mysql2"; import {Database} from "bun:sqlite"; /* import {obtenerLinks} from './LinksAnimes/obtenerLinks'; import {crearAnime} from './Admin/crearAnime'; import {obtenerTodosAnimes} from './Admin/obtenerTodosAnimes'; import {obtenerOPs} from './Admin/OP/obtenerOPs'; import {nuevoOP} from './Admin/OP/nuevoOP'; import {obtenerEDs} from './Admin/ED/obtenerEDs'; import {nuevoED} from './Admin/ED/nuevoED'; import {obtenerVariantes} from './Admin/Eps/obtenerVariantes'; import {obtenerLinks} from './Admin/Eps/obtenerLinks'; import {crearLink} from './Admin/Eps/crearLink'; import {estadisticas} from './Admin/Eps/estadisticas'; */ console.log("express??"); const app = express(); const port = 3485; const expressApp = (app: core.Express) => { app.use(express.json()); app.use(express.urlencoded()); // Serve the frontend app.use(express.static("dist")); app.post('/links', require('./LinksAnimes/obtenerLinks').obtenerLinks); app.put('/links', require('./LinksAnimes/modificarLink').modificarLink); app.put('/a/', require('./Admin/crearAnime').crearAnime); app.get('/a/', require('./Admin/obtenerTodosAnimes').obtenerTodosAnimes); app.get('/op/:id', require('./Admin/OP/obtenerOPs').obtenerOPs); app.post('/op/', require('./Admin/OP/nuevoOP').nuevoOP); app.get('/ed/:anime_ID', require('./Admin/ED/obtenerEDs').obtenerEDs); app.post('/ed/', require('./Admin/ED/nuevoED').nuevoED); app.get('/eps/variantes/:anime_ID', require('./Admin/Eps/obtenerVariantes').obtenerVariantes); app.get('/eps/links/:opcion_ID', require('./Admin/Eps/obtenerLinks').obtenerLinks); app.post('/eps/links/', require('./Admin/Eps/crearLink').crearLink); app.get('/estadisticas', require('./Admin/Eps/estadisticas').estadisticas); } const sqlite = new Database('pseudosubs.sqlite'); export const sqliteConnection = { escape: (str: string): string => { return str; }, query: (query: string, callback: (err: Error|null, rows: any) => void) => { const q = sqlite.query(query); try { const result = q.all(); callback(null, result); } catch (e) { callback(e, null); } }, }; expressApp(app); app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`); }); // module.exports.conexionMySQL = conexionMySQL;