diff --git a/client/src/components/dashboard/Chart.jsx b/client/src/components/dashboard/Chart.jsx index 739dfd2..af55509 100644 --- a/client/src/components/dashboard/Chart.jsx +++ b/client/src/components/dashboard/Chart.jsx @@ -60,8 +60,8 @@ const chartConfig = { label: "Entertainment", color: "var(--color-subly-brand-blue)", }, - AI_TOOLS: { label: "AI Tools", color: "var(--color-ai)" }, - STORAGE: { label: "Storage", color: "var(--color-storage)" }, + AI_TOOLS: { label: "Ai Tools", color: "var(--color-subly-success)" }, + STORAGE: { label: "Storage", color: "var(--color-subly-warning)" }, PRODUCTIVITY: { label: "Productivity", color: "var(--color-subly-brand-purple)", diff --git a/server/server.js b/server/server.js index 0caad15..56367f1 100644 --- a/server/server.js +++ b/server/server.js @@ -16,7 +16,7 @@ import { currencyRouters } from "./src/routes/rate.route.js"; import { historyRouter } from "./src/routes/history.route.js"; import cors from "cors"; import { notificationRouter } from "./src/routes/notification.route.js"; -import { jobsMaintainanceRouter } from "./src/routes/maintainance.route.js"; +import { jobsMaintenanceRouter } from "./src/routes/maintenance.route.js"; @@ -68,7 +68,7 @@ app.use(cookieParser()); app.use("/api/auth", authLimiter, authRouter); app.use("/api/me", requireAuth, meRouter); -app.use("/api/jobs", jobsMaintainanceRouter); +app.use("/api/jobs", jobsMaintenanceRouter); app.use("/api/rate", currencyRouters); app.use("/api/refresh", apiLimiter, refreshRouter); app.use("/api/subscription", requireAuth, subscriptionRouter); diff --git a/server/src/controllers/maintainance.controller.js b/server/src/controllers/maintainance.controller.js deleted file mode 100644 index 662723d..0000000 --- a/server/src/controllers/maintainance.controller.js +++ /dev/null @@ -1,21 +0,0 @@ -import { sendExpired } from "../jobs/sendExpired.js"; -import { sendReminder } from "../jobs/sendReminder.js"; -import { syncRate } from "../jobs/syncRate.js"; - - -export async function jobsMaintainance(req, res, next) { - try { - const results = await Promise.allSettled([ - syncRate(), - sendReminder(), - sendExpired() - ]); - - return res.json({ - message: "Maintainance completed", - results - }) - } catch (err) { - next(err); - } -} diff --git a/server/src/controllers/maintenance.controller.js b/server/src/controllers/maintenance.controller.js new file mode 100644 index 0000000..2602d24 --- /dev/null +++ b/server/src/controllers/maintenance.controller.js @@ -0,0 +1,21 @@ +import { sendExpired } from "../jobs/sendExpired.js"; +import { sendReminder } from "../jobs/sendReminder.js"; +import { syncRate } from "../jobs/syncRate.js"; + + +export async function jobsMaintenance(req, res, next) { + try { + const results = await Promise.allSettled([ + syncRate(), + sendReminder(), + sendExpired(), + ]); + + return res.json({ + message: "Maintainance completed", + results, + }); + } catch (err) { + next(err); + } +} diff --git a/server/src/jobs/sendExpired.js b/server/src/jobs/sendExpired.js index 9f64b7c..640ce0d 100644 --- a/server/src/jobs/sendExpired.js +++ b/server/src/jobs/sendExpired.js @@ -16,6 +16,3 @@ export async function sendExpired() { }); } -sendExpired().catch(console.error).finally(async () => { - await prisma.$disconnect() -}) \ No newline at end of file diff --git a/server/src/middlewares/verifyCronSecret.middleware.js b/server/src/middlewares/verifyCronSecret.middleware.js index 5677171..9f0eeb5 100644 --- a/server/src/middlewares/verifyCronSecret.middleware.js +++ b/server/src/middlewares/verifyCronSecret.middleware.js @@ -1,4 +1,4 @@ -import { env } from "../config/env"; +import { env } from "../config/env.js"; export function verifyCronSecret(req, res, next) { const secret = req.headers["x-cron-secret"]; diff --git a/server/src/routes/maintainance.route.js b/server/src/routes/maintainance.route.js deleted file mode 100644 index d9f6952..0000000 --- a/server/src/routes/maintainance.route.js +++ /dev/null @@ -1,8 +0,0 @@ - -import express from 'express' -import { jobsMaintainance } from '../controllers/maintainance.controller.js'; - - -export const jobsMaintainanceRouter = express.Router(); - -jobsMaintainanceRouter.post('/maintainance', jobsMaintainance) \ No newline at end of file diff --git a/server/src/routes/maintenance.route.js b/server/src/routes/maintenance.route.js new file mode 100644 index 0000000..2443203 --- /dev/null +++ b/server/src/routes/maintenance.route.js @@ -0,0 +1,9 @@ + +import express from 'express' +import { jobsMaintenance } from "../controllers/maintenance.controller.js"; +import { verifyCronSecret } from "../middlewares/verifyCronSecret.middleware.js"; + + +export const jobsMaintenanceRouter = express.Router(); + +jobsMaintenanceRouter.post("/maintenance", verifyCronSecret, jobsMaintenance); \ No newline at end of file