clean code
This commit is contained in:
18
index.js
18
index.js
@@ -7,8 +7,8 @@ let express = require("express");
|
||||
const path = require("path");
|
||||
const bodyParser = require("body-parser");
|
||||
const MarketAlert = require("./app/models/marketalert");
|
||||
const sendNotification = require("./app/lib/sendnotification");
|
||||
const scrapTheItems = require("./app/lib/scraptheitems");
|
||||
const sendNotification = require("./app/lib/sendNotification");
|
||||
const scrapTheItems = require("./app/lib/scrapTheItems");
|
||||
const sequelize = require("./app/models/index").sequelize;
|
||||
const Twocheckout = require("2checkout-node");
|
||||
const layout = require('express-layout');
|
||||
@@ -26,7 +26,7 @@ app.use(layout());
|
||||
const compression = require('compression');
|
||||
app.use(compression());
|
||||
|
||||
app.get("/api/sendnotifications", async function(req, res) {
|
||||
app.get("/api/sendnotifications", async (req, res) => {
|
||||
let marketAlerts = await MarketAlert.findAll();
|
||||
|
||||
let lastDateUpdate = await Promise.all(
|
||||
@@ -59,7 +59,7 @@ app.get("/api/items/:url", async (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.post("/api/marketalerts", function(req, res) {
|
||||
app.post("/api/marketalerts", (req, res) => {
|
||||
const { email, last_date, olx_url } = req.body;
|
||||
console.log(email, last_date, olx_url);
|
||||
sequelize.sync().then(() => {
|
||||
@@ -75,7 +75,7 @@ app.post("/api/marketalerts", function(req, res) {
|
||||
});
|
||||
});
|
||||
|
||||
app.post("/api/payforalert", function(request, response) {
|
||||
app.post("/api/payforalert", (req, res) => {
|
||||
let tco = new Twocheckout({
|
||||
sellerId: "901402692",
|
||||
privateKey: "A28DCE5F-9292-405C-8161-F84D8BB83AFC",
|
||||
@@ -84,7 +84,7 @@ app.post("/api/payforalert", function(request, response) {
|
||||
|
||||
let params = {
|
||||
merchantOrderId: "123",
|
||||
token: request.body.token,
|
||||
token: req.body.token,
|
||||
currency: "USD",
|
||||
total: "2.00",
|
||||
billingAddr: {
|
||||
@@ -94,16 +94,16 @@ app.post("/api/payforalert", function(request, response) {
|
||||
state: "BiH",
|
||||
zipCode: "71000",
|
||||
country: "BiH",
|
||||
email: request.body.email,
|
||||
email: req.body.email,
|
||||
phoneNumber: "5555555555"
|
||||
}
|
||||
};
|
||||
|
||||
tco.checkout.authorize(params, function(error, data) {
|
||||
if (error) {
|
||||
response.send(error.message);
|
||||
res.send(error.message);
|
||||
} else {
|
||||
response.send(data.response.responseMsg);
|
||||
res.send(data.response.responseMsg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user