44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
const syncThaiProfilePriceSlotApiInfo = {
|
|
version: 1,
|
|
semver: "1.0.1",
|
|
changelogs: [
|
|
"17/4/25, create endpoint map @Pakin",
|
|
"29/5/25, fix price slot sync incorrect @Pakin",
|
|
],
|
|
desc: "Sync price between sheets expected sheet with prefix `PriceSlot` for country `tha` (Thai), | does not allow modification to function while running except reloaded, Endpoints:\n/run/now,/run/test\n",
|
|
};
|
|
|
|
let syncProfilePriceSlotsTask = CronJobs.doEveryMidnight(() => {
|
|
GoogleFunctions.syncProfilePrice(sheet, "tha", false);
|
|
}, "sync-gg-price_slot_tha");
|
|
|
|
syncProfilePriceSlotsTask.on("stop-sync-gg-price_slot_tha_test", () =>
|
|
syncProfilePriceSlotsTask.stop(),
|
|
);
|
|
|
|
cronTasks.push(syncProfilePriceSlotsTask);
|
|
|
|
endpointMap = {
|
|
"": function (req, res, next) {
|
|
res.locals.title = "Sync Thai Price Slots";
|
|
res.locals.version = syncThaiProfilePriceSlotApiInfo.version;
|
|
res.locals.desc = syncThaiProfilePriceSlotApiInfo.desc;
|
|
|
|
res.render("apiInfo");
|
|
},
|
|
"info": function(req, res, next) {
|
|
res.json(syncThaiProfilePriceSlotApiInfo);
|
|
},
|
|
"run/now": async function (req, res, next) {
|
|
// res.json({ status: "running" });
|
|
await GoogleFunctions.syncProfilePrice(sheet, "tha", false);
|
|
res.json({ status: "success", message: "Force run `Sync Thai Price Slots`" });
|
|
// res.send("Force run `Sync Thai Price Slots`");
|
|
},
|
|
"run/test": async function (req, res, next) {
|
|
// res.json({ status: "running" });
|
|
await GoogleFunctions.syncProfilePrice(sheet, "tha", true);
|
|
res.json({ status: "success", message: "Force run `Sync Thai Price Slots` test mode" });
|
|
// res.send("Force run `Sync Thai Price Slots` test mode");
|
|
},
|
|
};
|