feat(apihits): so i can see if what end points are being used and when and how often
This commit is contained in:
@@ -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