pseudosubs-v1/srv/Admin/ED/nuevoED.ts

35 lines
985 B
TypeScript
Raw Normal View History

2024-02-29 13:15:31 +00:00
import {sqliteConnection as con} from "../../index";
interface Data {
anime_ID: number,
num_ED: number,
nombre: string,
artista: string,
eps: string
}
2024-02-29 13:15:31 +00:00
export const nuevoED = (req: any, res: any) => {
const YAML = require('yaml');
const data: Data = YAML.parse(req.body.data);
if (data) {
const query = `INSERT INTO ED (anime_ID, num_ED, nombre, artista, eps) VALUES ( ${data.anime_ID}, ${data.num_ED},
${con.escape(data.nombre)}, ${con.escape(data.artista)}, ${con.escape(data.eps)} )`;
2024-02-29 13:15:31 +00:00
con.query(query, (err) => {
if (!err) {
res.send("exito: true");
} else {
res.send("error: true");
console.log("Error al ejecutar query en /Admin/ED/nuevoED (con.query):\n" + query + "\n" + err);
}
});
} else {
res.send("error: true");
console.log("Error. La data no existe en /Admin/ED/nuevoED (con.connect)");
}
};