initialize

This commit is contained in:
Pakin 2025-08-06 16:01:57 +07:00
commit 99b6232436
24 changed files with 3872 additions and 0 deletions

31
plugins/heartbeat.js Normal file
View file

@ -0,0 +1,31 @@
// continue;
const heartbeatApiInfo = {
version: 1,
changelogs: [
"17/4/25, create endpoint map @Pakin"
],
};
let heartbeatTask = CronJobs.doEveryMinute(() => {
Log.debug("[hb] test heartbeat");
Log.debug(`[hb] current running tasks: ${JSON.stringify(CronJobs.getAllRunning.size)}`);
heartbeatTask.stop();
}, 'heartbeat');
heartbeatTask.on('stop-heartbeat', () => heartbeatTask.stop());
cronTasks[0] = heartbeatTask;
endpointMap = {
'': function(req, res, next){
res.locals.title = "heartbeat";
res.locals.version = heartbeatApiInfo.version;
res.locals.task_num = CronJobs.getAllRunning.size;
res.render("heartbeat");
},
};

View file

@ -0,0 +1,9 @@
let syncProfilePriceSlot8Task = CronJobs.doEveryMidnight(() => {
}, 'sync-price-slot-aot');
syncProfilePriceSlot8Task.on('stop-sync-price-slot-aot', () => syncProfilePriceSlot8Task.stop());
cronTasks.push(syncProfilePriceSlot8Task);

View file

@ -0,0 +1,37 @@
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");
},
"run/now": function (req, res, next) {
GoogleFunctions.syncProfilePrice(sheet, "tha", false);
res.send("Force run `Sync Thai Price Slots`");
},
"run/test": function (req, res, next) {
GoogleFunctions.syncProfilePrice(sheet, "tha", true);
res.send("Force run `Sync Thai Price Slots` test mode");
},
};