Lots of updates and cleaning up.

This commit is contained in:
2026-02-14 12:08:23 -06:00
parent 7466bbdeac
commit 3ab443790c
17 changed files with 484 additions and 52 deletions
+26
View File
@@ -0,0 +1,26 @@
import { Hono } from "hono/tiny";
import { createRoute } from "../../../modules/api-utils/createRoute";
import { companies } from "../../../managers/companies";
import { apiResponse } from "../../../modules/api-utils/apiResponse";
import { ContentfulStatusCode } from "hono/utils/http-status";
import { authMiddleware } from "../../middleware/authorization";
/* /v1/company/companies/[id]/configurations */
export default createRoute(
"get",
["/companies/:identifier/configurations"],
async (c) => {
const company = await companies.fetch(c.req.param("identifier"));
const configurations = await company.fetchConfigurations();
const response = apiResponse.successful(
"Company Configurations Fetched Successfully!",
configurations,
);
return c.json(response, response.status as ContentfulStatusCode);
},
authMiddleware({
permissions: ["company.fetch", "company.fetch.configurations"],
}),
);
@@ -1,14 +1,15 @@
import { Hono } from "hono/tiny";
import { createRoute } from "../../modules/api-utils/createRoute";
import { companies } from "../../managers/companies";
import { apiResponse } from "../../modules/api-utils/apiResponse";
import { createRoute } from "../../../modules/api-utils/createRoute";
import { companies } from "../../../managers/companies";
import { apiResponse } from "../../../modules/api-utils/apiResponse";
import { ContentfulStatusCode } from "hono/utils/http-status";
import { authMiddleware } from "../middleware/authorization";
import { authMiddleware } from "../../middleware/authorization";
/* /v1/company/[id] */
/* /v1/company/companies/[id] */
export default createRoute(
"get",
["/company/:identifier"],
["/companies/:identifier"],
async (c) => {
const company = await companies.fetch(c.req.param("identifier"));
+8 -2
View File
@@ -12,9 +12,15 @@ export default createRoute(
async (c) => {
const page = new Number(c.req.query("page") ?? 1) as number;
const rpp = new Number(c.req.query("rpp") ?? 30) as number; // Records Per Page
const companyQty = await companies.count();
const search = c.req.query("search") as string;
const data = await companies.fetchPages(page, rpp);
const data = search
? await companies.search(search, page, rpp)
: await companies.fetchPages(page, rpp);
const companyQty = search
? (await companies.search(search, 1, 999999)).length
: await companies.count();
let response = apiResponse.successful(
"Companies Fetched Successfully!",
+3 -2
View File
@@ -1,4 +1,5 @@
import { default as fetchAll } from "./fetchAll";
import { default as fetch } from "./fetch";
import { default as fetch } from "./[id]/fetch";
import { default as configurations } from "./[id]/configurations";
export { fetch, fetchAll };
export { configurations, fetch, fetchAll };