-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
63 lines (52 loc) · 1.68 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
process.on("uncaughtException", (err) => {
console.error(err);
process.exit(1);
});
process.on("unhandledRejection", (err) => {
console.error(err);
});
import express from "express";
import { createServer } from "http";
import EbayService from "./service/ebay";
import WooCommerceService from "./service/wooCommerce";
const app = express();
const server = createServer(app);
const port = process.env.PORT || 4000;
app.get("/ebay/item/:id", (req, res) => {
EbayService.getItem(req.params.id)
.then((data) => res.json(data))
.catch((err) => res.status(500).json(err));
});
app.get("/wooCommerce/item/:id", (req, res) => {
WooCommerceService.getItem(req.params.id)
.then((data) => res.json(data))
.catch((err) => res.status(500).json(err));
});
app.get("/wooCommerce/attributes", (req, res) => {
WooCommerceService.getAttributes(req.params.id)
.then((data) => res.json(data))
.catch((err) => res.status(500).json(err));
});
app.get("/wooCommerce/syncCategories", (req, res) => {
WooCommerceService.syncCategories()
.then((data) => res.json(data))
.catch((err) => res.status(500).json(err));
});
app.get("/wooCommerce/products", (req, res) => {
WooCommerceService.getProducts()
.then((data) => res.json(data))
.catch((err) => res.status(500).json(err));
});
app.get("/items", (req, res) => {
EbayService.getItems()
.then((data) => res.json(data))
.catch((err) => res.status(500).json(err));
});
app.get("/sync", (req, res) => {
EbayService.syncProductsToWooCommerce()
.then((data) => res.json(data))
.catch((err) => res.status(500).json(err));
});
server.listen(port, (req, res) => {
console.log(`server listening on port: ${port}`);
});