-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Release [0.56.13] * tavano linx logs * remove cf headers * new headers * Update transform.ts (#955) Added additionalProperty displayPrice in transform.ts linx * Fix auctions * remove console log * check --------- Co-authored-by: viktormarinho <viktormpcs@gmail.com> Co-authored-by: italofg <99489312+italofg@users.noreply.github.com> Co-authored-by: Matheus Gaudencio do Rêgo <matheusgr@users.noreply.github.com>
- Loading branch information
1 parent
dde531f
commit 6aff05c
Showing
9 changed files
with
148 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Auction } from "../../utils/types/auctionAPI.ts"; | ||
import type { AppContext } from "../../../linx/mod.ts"; | ||
|
||
let cachedPromise: Promise<Auction[]> | null = null; | ||
let lastUpdate: number = Date.now(); | ||
/** | ||
* @title Linx Integration | ||
* @description Search Wishlist loader | ||
*/ | ||
const loader = ( | ||
_props: unknown, | ||
_req: Request, | ||
ctx: AppContext, | ||
): Promise<Auction[] | null> => { | ||
const { layer } = ctx; | ||
|
||
if (cachedPromise && Date.now() - lastUpdate < (60 * 1000)) { | ||
return cachedPromise; | ||
} | ||
|
||
lastUpdate = Date.now(); | ||
const responsePromise = layer | ||
["POST /v1/Catalog/API.svc/web/SearchProductAuctions"]( | ||
{}, | ||
// @ts-ignore body is required | ||
{ body: {} }, | ||
).then(async (response) => { | ||
return await response.json(); | ||
}); | ||
|
||
cachedPromise = responsePromise; | ||
return responsePromise; | ||
}; | ||
|
||
export const cache = "stale-while-revalidate"; | ||
|
||
export const cacheKey = (_props: unknown, req: Request, _ctx: AppContext) => { | ||
const url = new URL(req.url); | ||
url.pathname = "/v1/Catalog/API.svc/web/SearchProductAuctions"; | ||
return url.href; | ||
}; | ||
|
||
export default loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type Auction = { | ||
BidCount: number; | ||
ExecutionFrom: string; | ||
ExecutionTo: string; | ||
IsVisible: boolean; | ||
LastBidAmount: number; | ||
LastBidCustomerID: number; | ||
LastBidCustomerName: string; | ||
LastBidCustomerState: string; | ||
Name: string; | ||
ProductAuctionID: number; | ||
ProductID: number; | ||
SkuID: number; | ||
Status: number; | ||
StatusInternal: string; | ||
VisibleFrom: string; | ||
VisibleTo: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters