2018-11-20 01:28:50 +00:00
|
|
|
import express from 'express';
|
2018-12-21 00:13:51 +00:00
|
|
|
import * as core from "express-serve-static-core";
|
2024-02-29 15:32:18 +00:00
|
|
|
import Database from 'better-sqlite3';
|
2018-11-20 01:28:50 +00:00
|
|
|
|
2024-02-29 01:21:49 +00:00
|
|
|
const app = express();
|
2024-02-29 14:14:57 +00:00
|
|
|
const port = 3485;
|
2024-02-29 01:21:49 +00:00
|
|
|
|
|
|
|
const expressApp = (app: core.Express) => {
|
2018-11-20 21:52:25 +00:00
|
|
|
|
|
|
|
app.use(express.json());
|
|
|
|
app.use(express.urlencoded());
|
2018-11-20 01:28:50 +00:00
|
|
|
|
2024-02-29 14:14:57 +00:00
|
|
|
// Serve the frontend
|
|
|
|
app.use(express.static("dist"));
|
2018-11-20 21:52:25 +00:00
|
|
|
|
|
|
|
app.post('/links', require('./LinksAnimes/obtenerLinks').obtenerLinks);
|
2024-02-29 13:15:31 +00:00
|
|
|
app.put('/links', require('./LinksAnimes/modificarLink').modificarLink);
|
2018-11-20 21:52:25 +00:00
|
|
|
|
2018-11-22 16:46:11 +00:00
|
|
|
app.put('/a/', require('./Admin/crearAnime').crearAnime);
|
|
|
|
app.get('/a/', require('./Admin/obtenerTodosAnimes').obtenerTodosAnimes);
|
|
|
|
|
2018-12-13 01:10:51 +00:00
|
|
|
app.get('/op/:id', require('./Admin/OP/obtenerOPs').obtenerOPs);
|
|
|
|
app.post('/op/', require('./Admin/OP/nuevoOP').nuevoOP);
|
|
|
|
|
2018-12-20 21:30:16 +00:00
|
|
|
app.get('/ed/:anime_ID', require('./Admin/ED/obtenerEDs').obtenerEDs);
|
|
|
|
app.post('/ed/', require('./Admin/ED/nuevoED').nuevoED);
|
|
|
|
|
2018-12-16 03:49:59 +00:00
|
|
|
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);
|
|
|
|
|
2018-12-21 00:13:51 +00:00
|
|
|
app.get('/estadisticas', require('./Admin/Eps/estadisticas').estadisticas);
|
2018-11-20 01:28:50 +00:00
|
|
|
}
|
2018-12-21 00:13:51 +00:00
|
|
|
|
2024-02-29 15:32:18 +00:00
|
|
|
let sqlite = new Database('pseudosubs.sqlite');
|
2024-02-29 13:15:31 +00:00
|
|
|
|
|
|
|
export const sqliteConnection = {
|
|
|
|
escape: (str: string): string => {
|
|
|
|
return str;
|
|
|
|
},
|
|
|
|
query: (query: string, callback: (err: Error|null, rows: any) => void) => {
|
2024-02-29 15:32:18 +00:00
|
|
|
const q = sqlite.prepare(query);
|
2024-02-29 13:15:31 +00:00
|
|
|
try {
|
|
|
|
const result = q.all();
|
|
|
|
callback(null, result);
|
2024-02-29 15:32:18 +00:00
|
|
|
} catch (e: any) {
|
2024-02-29 13:15:31 +00:00
|
|
|
callback(e, null);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-02-29 01:21:49 +00:00
|
|
|
expressApp(app);
|
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Example app listening at http://localhost:${port}`);
|
|
|
|
});
|