26 lines
751 B
TypeScript
26 lines
751 B
TypeScript
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/count */
|
|
export default createRoute(
|
|
"get",
|
|
["/count"],
|
|
async (c) => {
|
|
const count = await companies.count();
|
|
|
|
const response = apiResponse.successful(
|
|
"Company count fetched successfully!",
|
|
{
|
|
count,
|
|
},
|
|
);
|
|
|
|
return c.json(response, response.status as ContentfulStatusCode);
|
|
},
|
|
authMiddleware({ permissions: ["company.fetch.many"] }),
|
|
);
|