feat(apihits): so i can see if what end points are being used and when and how often
This commit is contained in:
@@ -4,6 +4,7 @@ import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
|
||||
import { verify } from "hono/jwt";
|
||||
import { consumeMaterial } from "../controller/materials/consumeMaterial.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -37,7 +38,19 @@ app.openapi(
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
const { data, error } = await tryCatch(c.req.json());
|
||||
|
||||
if (error) {
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Missing data please try again",
|
||||
error,
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
apiHit(c, { endpoint: "/consume", lastBody: data });
|
||||
const authHeader = c.req.header("Authorization");
|
||||
const token = authHeader?.split("Bearer ")[1] || "";
|
||||
|
||||
@@ -45,7 +58,7 @@ app.openapi(
|
||||
const payload = await verify(token, process.env.JWT_SECRET!);
|
||||
try {
|
||||
//return apiReturn(c, true, access?.message, access?.data, 200);
|
||||
const data = await c.req.json();
|
||||
|
||||
const consume = await consumeMaterial(data, payload);
|
||||
return c.json(
|
||||
{ success: consume?.success, message: consume?.message },
|
||||
|
||||
@@ -3,6 +3,7 @@ import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { ordersIn } from "../../controller/dm/ordersIn/ordersIn.js";
|
||||
import { verify } from "hono/jwt";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -31,7 +32,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/postbulkorders" });
|
||||
const body = await c.req.parseBody();
|
||||
const authHeader = c.req.header("Authorization");
|
||||
const token = authHeader?.split("Bearer ")[1] || "";
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ordersIn } from "../../controller/dm/ordersIn/ordersIn.js";
|
||||
import { verify } from "hono/jwt";
|
||||
import { forecastIn } from "../../controller/dm/forecast/forecastIn.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -32,7 +33,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/postforecastin" });
|
||||
const body = await c.req.parseBody();
|
||||
const authHeader = c.req.header("Authorization");
|
||||
const token = authHeader?.split("Bearer ")[1] || "";
|
||||
|
||||
@@ -4,6 +4,7 @@ import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { standardTemplate } from "../../controller/dm/ordersIn/createTemplate.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { standardForCastTemplate } from "../../controller/dm/forecast/createTemplate.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -32,7 +33,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/bulkforcasttemplate" });
|
||||
const defaultFilename = `bulkForcastTemplate-${format(
|
||||
new Date(Date.now()),
|
||||
"M-d-yyyy"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { format } from "date-fns";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { standardTemplate } from "../../controller/dm/ordersIn/createTemplate.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -31,7 +32,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/bulkorderstemplate" });
|
||||
const defaultFilename = `bulkOrdersInTemplate-${format(
|
||||
new Date(Date.now()),
|
||||
"M-d-yyyy"
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { getCycleCountCheck } from "../controller/warehouse/cycleCountChecks/getCycleCountCheck.js";
|
||||
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -30,7 +31,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/cyclecountcheck" });
|
||||
const { data: body, error: be } = await tryCatch(c.req.json());
|
||||
|
||||
if (be) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { lanesToExcel } from "../controller/warehouse/cycleCountChecks/exportCycleCountData.js";
|
||||
import { format } from "date-fns";
|
||||
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -31,7 +32,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/getcyclecount" });
|
||||
const defaultFilename = `cycleCount-${format(
|
||||
new Date(Date.now()),
|
||||
"M-d-yyyy"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { getCycleCountCheck } from "../controller/warehouse/cycleCountChecks/getCycleCountCheck.js";
|
||||
import { getPPOO } from "../controller/warehouse/ppoo/getPPOO.js";
|
||||
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -31,7 +32,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/outbound" });
|
||||
|
||||
const body = await c.req.json();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { getCycleCountCheck } from "../controller/warehouse/cycleCountChecks/getCycleCountCheck.js";
|
||||
import { getPPOO } from "../controller/warehouse/ppoo/getPPOO.js";
|
||||
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -31,7 +32,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/getppoo" });
|
||||
|
||||
const { data: ppoo, error } = await tryCatch(getPPOO());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { authMiddleware } from "../../auth/middleware/authMiddleware.js";
|
||||
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
import { verify } from "hono/jwt";
|
||||
import { returnMaterial } from "../controller/materials/returnMaterial.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -36,7 +37,19 @@ app.openapi(
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
const { data, error } = await tryCatch(c.req.json());
|
||||
|
||||
if (error) {
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Missing data please try again",
|
||||
error,
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
apiHit(c, { endpoint: "/return", lastBody: data });
|
||||
const authHeader = c.req.header("Authorization");
|
||||
const token = authHeader?.split("Bearer ")[1] || "";
|
||||
|
||||
@@ -44,7 +57,7 @@ app.openapi(
|
||||
const payload = await verify(token, process.env.JWT_SECRET!);
|
||||
try {
|
||||
//return apiReturn(c, true, access?.message, access?.data, 200);
|
||||
const data = await c.req.json();
|
||||
|
||||
const consume = await returnMaterial(data, payload);
|
||||
return c.json(
|
||||
{ success: consume?.success, message: consume?.message },
|
||||
|
||||
@@ -3,6 +3,8 @@ import { verify } from "hono/jwt";
|
||||
import { authMiddleware } from "../../../auth/middleware/authMiddleware.js";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { createSiloAdjustment } from "../../controller/siloAdjustments/createSiloAdjustment.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -23,7 +25,19 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
const { data, error } = await tryCatch(c.req.json());
|
||||
|
||||
if (error) {
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Missing data please try again",
|
||||
error,
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
apiHit(c, { endpoint: "/createsiloadjustment", lastBody: data });
|
||||
const authHeader = c.req.header("Authorization");
|
||||
const token = authHeader?.split("Bearer ")[1] || "";
|
||||
|
||||
@@ -31,7 +45,6 @@ app.openapi(
|
||||
const payload = await verify(token, process.env.JWT_SECRET!);
|
||||
try {
|
||||
//return apiReturn(c, true, access?.message, access?.data, 200);
|
||||
const data = await c.req.json();
|
||||
const createSiloAdj = await createSiloAdjustment(
|
||||
data,
|
||||
payload.user
|
||||
|
||||
@@ -4,6 +4,7 @@ import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { getOpenOrders } from "../../../dataMart/controller/getOpenOrders.js";
|
||||
import axios from "axios";
|
||||
import { getSiloAdjustments } from "../../controller/siloAdjustments/getSiloAdjustments.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
// const Body = z.object({
|
||||
@@ -26,6 +27,7 @@ app.openapi(
|
||||
}),
|
||||
async (c: any) => {
|
||||
const customer: any = c.req.queries();
|
||||
apiHit(c, { endpoint: "/getsilosdjustment" });
|
||||
|
||||
// make sure we have a vaid user being accessed thats really logged in
|
||||
//apiHit(c, { endpoint: `api/logger/logs/id` });
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { authMiddleware } from "../../../auth/middleware/authMiddleware.js";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { getStockSiloData } from "../../controller/siloAdjustments/getCurrentStockSiloData.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -21,7 +22,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/getstocksilo" });
|
||||
|
||||
try {
|
||||
//return apiReturn(c, true, access?.message, access?.data, 200);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { authMiddleware } from "../../../auth/middleware/authMiddleware.js";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { createSiloAdjustment } from "../../controller/siloAdjustments/createSiloAdjustment.js";
|
||||
import { postSiloComment } from "../../controller/siloAdjustments/postComment.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -42,7 +43,7 @@ app.openapi(
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
apiHit(c, { endpoint: "/postcomment" });
|
||||
const authHeader = c.req.header("Authorization");
|
||||
const token = authHeader?.split("Bearer ")[1] || "";
|
||||
const { adjId } = c.req.valid("param");
|
||||
|
||||
Reference in New Issue
Block a user