Files
scheduler-app/index.js
teddys48 ca5d3cc3e0
All checks were successful
Build and Deploy Scheduler / cleaning (push) Successful in 3s
Build and Deploy Scheduler / build_image (push) Successful in 1m31s
Build and Deploy Scheduler / deploy (push) Successful in 53s
update
2026-02-13 10:08:35 +07:00

55 lines
1.1 KiB
JavaScript

const express = require("express");
const app = express();
const port = 3000;
const cron = require("node-cron");
const axios = require("axios");
const { exec } = require("child_process");
app.get("/", (req, res) => {
res.json("Scheduler App");
});
cron.schedule(
"0 9 * * *",
async () => {
const module = "Birthday Notification";
try {
let res = await axios.get(
"http://email-notification:9997/birthday-notification",
);
console.log(module, "success", res.data);
} catch (error) {
console.error(module, "error", error.message);
}
},
{
timezone: "Asia/Jakarta",
},
);
cron.schedule(
"1 9 * * *",
async () => {
const module = "Workanniversary";
try {
let res = await axios.get(
"http://email-notification:9997/workanniversary-notification",
);
console.log(module, "success", res.data);
} catch (error) {
console.error(module, "error", error.message);
}
},
{
timezone: "Asia/Jakarta",
},
);
app.use((req, res) => {
res.json("What are you looking for?!");
});
app.listen(port, () => {
console.log(`scheduler app listening on port ${port}`);
});