Arreglo de errores y eliminado las pruebas de notificaciones push.

This commit is contained in:
Fernando 2019-05-10 15:18:16 -05:00
parent 532ebe9ab2
commit 3ce363080a

View File

@ -3,7 +3,12 @@ const mysql = require("mysql");
import obtenerAnimes from "./Anime/obtenerAnime"
import obtenerTodosAnimes from "./Anime/obtenerTodosAnimes"
const webPush = require("web-push");
export const webPush = require("web-push");
webPush.setVapidDetails(
"mailto:tbyuyfcjjll@gmail.com",
"BPA_MfechJ8EwyMC_5-GZsWFtjPCD6f2qAzW5ouxnMs73mGTsgtD47of0pO1rKtpyWiWKE8yZVHHzTGhLHbfVRI",
"6dOp0WChG-fLFSo9hRnMUn5S1BVBm3KhK9r0m4L-GoA"
);
export const con = mysql.createConnection({
host: "127.0.0.1",
@ -25,18 +30,15 @@ export const fun = app => {
app.use(bodyParser.urlencoded({ extended: true }));
// app.use(bodyParser.json);
webPush.setVapidDetails(
"mailto:tbyuyfcjjll@gmail.com",
"BPA_MfechJ8EwyMC_5-GZsWFtjPCD6f2qAzW5ouxnMs73mGTsgtD47of0pO1rKtpyWiWKE8yZVHHzTGhLHbfVRI",
"6dOp0WChG-fLFSo9hRnMUn5S1BVBm3KhK9r0m4L-GoA"
);
app.post("/anime/:id", obtenerAnimes);
app.post("/anime", obtenerTodosAnimes);
app.post("/u/validar", require("./Usuarios/ValidarUsuario").fun);
app.post("/n/registrar", require("./Notificaciones/RegistrarSubcripcion").fun);
app.post("/n/subscrAnimes", require("./Notificaciones/obtenerSubscripcionAnimes").fun);
app.post("/n/subscribir/", require("./Notificaciones/suscribir").fun);
app.post("/n/desubscribir/", require("./Notificaciones/desuscribir").fun);
app.post("/op/:anime_ID", require("./OP-ED/obtenerOP").fun);
app.post("/ed/:anime_ID", require("./OP-ED/obtenerED").fun);
@ -64,29 +66,6 @@ export const fun = app => {
* Privada: 6dOp0WChG-fLFSo9hRnMUn5S1BVBm3KhK9r0m4L-GoA
* */
app.get("/n/test", (req, res) => {
console.log("Deberia enviar push...");
const payload = JSON.stringify({
title: "Push de ejemplo :3"
});
const subscripcion = {"endpoint":"https://fcm.googleapis.com/fcm/send/e-n6_jndfTw:APA91bGQrFOYgICLRm-diDHwJnI4909TiQB_FqnffBd6PnyyoiB2rDqehn41KxXMyw5Upa0IqqDnlr58-n3B9w6WCN6xY-sluDk8fpya928S_NPgJyAvbhFERN3Gqqy36s4J4OVDz6qL","expirationTime":null,"keys":{"p256dh":"BGNpJIqpEkJPjVZcccV42TdXQi-G3nt6gVWXIMkRs69fWyQeLN7K-sEBs7ffyCiosJm4ApwY9_ol2Q57Zv5fg08","auth":"DzzSWijI-WfBPWrI6eGcuw"}};
webPush.sendNotification(subscripcion, payload)
.then(response => {
console.log(JSON.stringify(response));
res.status(200);
res.send("Exito :D");
})
.catch(err => {
console.log(JSON.stringify(err));
res.status(400);
res.send(`Error al enviar push :c\n${err}`);
});
});
};
export default (app, http) => {