Skip to content

Commit

Permalink
add: cgn partner search endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
freddi301 committed Oct 30, 2024
1 parent e69fe64 commit c1f878c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/routers/features/cgn/merchants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { addHandler } from "../../../payloads/response";
import { sendFileFromRootPath } from "../../../utils/file";
import { addApiV1Prefix } from "../../../utils/strings";
import { publicRouter } from "../../public";
import { SearchRequest } from "../../../../generated/definitions/cgn/merchants/SearchRequest";

Check failure on line 25 in src/routers/features/cgn/merchants.ts

View workflow job for this annotation

GitHub Actions / checks

Cannot find module '../../../../generated/definitions/cgn/merchants/SearchRequest' or its corresponding type declarations.

export const cgnMerchantsRouter = Router();

Expand Down Expand Up @@ -74,6 +75,28 @@ addHandler(
}
);

addHandler(cgnMerchantsRouter, "post", addPrefix("/search"), (req, res) => {
if (SearchRequest.is(req.body)) {
return res.status(200).json({
items: merchantsAll
.filter(
merchant =>
merchant.name.toLowerCase().includes(req.body.token.toLowerCase()) ||
merchant.description
?.toLowerCase()
.includes(req.body.token.toLowerCase())
)
.map(merchant => ({
id: merchant.id,
name: merchant.name,
description: merchant.description,
newDiscounts: faker.datatype.boolean()
}))
});
}
return res.status(500);
});

addHandler(
cgnMerchantsRouter,
"post",
Expand Down

0 comments on commit c1f878c

Please sign in to comment.