Setup fetch and wip fetchall route for getting companies.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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/[id] */
|
||||
export default createRoute(
|
||||
"get",
|
||||
["/:identifier"],
|
||||
async (c) => {
|
||||
const company = await companies.fetch(c.req.param("identifier"));
|
||||
|
||||
const response = apiResponse.successful(
|
||||
"Company Fetched Successfully!",
|
||||
company,
|
||||
);
|
||||
return c.json(response, response.status as ContentfulStatusCode);
|
||||
},
|
||||
authMiddleware({ permissions: ["company.fetch"] }),
|
||||
);
|
||||
@@ -0,0 +1,31 @@
|
||||
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 */
|
||||
export default createRoute(
|
||||
"get",
|
||||
["/companies"],
|
||||
async (c) => {
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @TODO MAKE THIS WORK
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
const company = await companies.fetch(c.req.param("identifier"));
|
||||
|
||||
const response = apiResponse.successful(
|
||||
"Company Fetched Successfully!",
|
||||
company,
|
||||
);
|
||||
return c.json(response, response.status as ContentfulStatusCode);
|
||||
},
|
||||
authMiddleware({ permissions: ["company.fetch"] }),
|
||||
);
|
||||
Reference in New Issue
Block a user