11import { createHash } from "node:crypto" ;
22import { getApolloClient } from "@faustwp/core/dist/mjs/client" ;
3- import { Temporal } from "@js-temporal/polyfill" ;
3+ import { parseISO , compareAsc } from "date-fns" ; // Replaced Temporal with date-fns
44import { StatusCodes , getReasonPhrase } from "http-status-codes" ;
55import { FEED_QUERY , createFeed } from "@/lib/feed" ;
66
@@ -18,12 +18,9 @@ export default async function HandleFeeds(req, res) {
1818 query : FEED_QUERY ,
1919 } ) ;
2020
21- const last_modified = Temporal . PlainDateTime . from (
21+ const last_modified = parseISO (
2222 feed_data . last_modified . nodes [ 0 ] . modifiedGmt ,
23- {
24- overflow : "constrain" ,
25- } ,
26- ) ;
23+ ) ; // Replaced Temporal.PlainDateTime.from
2724
2825 // Create feed
2926 const feed = createFeed ( { feed_data, last_modified } ) ;
@@ -75,14 +72,14 @@ export default async function HandleFeeds(req, res) {
7572 ) ;
7673 res . setHeader ( "Content-Type" , resp . content_type ) ;
7774 res . setHeader ( "ETag" , etag_for_body ) ;
78- res . setHeader ( "Last-Modified" , last_modified . toString ( ) ) ;
75+ res . setHeader ( "Last-Modified" , last_modified . toUTCString ( ) ) ; // Adjusted to use Date's toUTCString()
7976
8077 if (
8178 // Checks if the `if_none_match` header matches current response' etag
8279 if_none_match === etag_for_body ||
8380 // Checks `if_modified_since` is after `last_modified`
8481 ( if_modified_since &&
85- Temporal . PlainDateTime . compare ( last_modified , if_modified_since ) < 0 )
82+ compareAsc ( last_modified , new Date ( if_modified_since ) ) < 0 ) // Replaced Temporal.PlainDateTime.compare
8683 ) {
8784 res . status ( StatusCodes . NOT_MODIFIED ) ;
8885 res . end ( ) ;
0 commit comments