Commit 9d18157 1 parent 4346b34 commit 9d18157 Copy full SHA for 9d18157
File tree 4 files changed +29
-3
lines changed
4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @curatedotfun/rss" ,
3
- "version" : " 0.0.7 " ,
3
+ "version" : " 0.0.8 " ,
4
4
"description" : " RSS plugin for curatedotfun" ,
5
5
"main" : " ./dist/index.js" ,
6
6
"types" : " ./dist/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
10
10
handleRawJson ,
11
11
handleGetItems ,
12
12
handleAddItem ,
13
+ handleHealth ,
13
14
} from "./routes.js" ;
14
15
import { authenticate } from "./middleware.js" ;
15
16
import { initializeFeed } from "./storage.js" ;
@@ -48,6 +49,7 @@ app.use("/api/*", authenticate);
48
49
49
50
// Register routes
50
51
app . get ( "/" , handleRoot ) ;
52
+ app . get ( "/health" , handleHealth ) ;
51
53
app . get ( "/rss.xml" , handleRss ) ;
52
54
app . get ( "/atom.xml" , handleAtom ) ;
53
55
app . get ( "/feed.json" , handleJsonFeed ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,20 @@ import { addItem, getItems } from "./storage.js";
5
5
import { ApiFormat , RssItem } from "./types.js" ;
6
6
import { sanitize } from "./utils.js" ;
7
7
8
+ /**
9
+ * Health check endpoint
10
+ */
11
+ export async function handleHealth ( c : Context ) : Promise < Response > {
12
+ return c . json (
13
+ {
14
+ status : "ok" ,
15
+ timestamp : new Date ( ) . toISOString ( ) ,
16
+ service : "rss-service" ,
17
+ } ,
18
+ 200 ,
19
+ ) ;
20
+ }
21
+
8
22
/**
9
23
* Health check and redirect to preferred format
10
24
*/
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ export default class RssPlugin
132
132
133
133
// Check if service is running with a health check
134
134
try {
135
- const healthCheckResponse = await fetch ( `${ this . serviceUrl } /` , {
135
+ const healthCheckResponse = await fetch ( `${ this . serviceUrl } /health ` , {
136
136
method : "GET" ,
137
137
} ) ;
138
138
@@ -245,6 +245,16 @@ export default class RssPlugin
245
245
}
246
246
247
247
try {
248
+ // Convert Date objects to ISO strings to ensure proper JSON serialization
249
+ const serializedItem = {
250
+ ...item ,
251
+ published :
252
+ item . published instanceof Date
253
+ ? item . published . toISOString ( )
254
+ : item . published ,
255
+ date : item . date instanceof Date ? item . date . toISOString ( ) : item . date ,
256
+ } ;
257
+
248
258
const response = await fetch ( `${ this . serviceUrl } /api/items` , {
249
259
method : "POST" ,
250
260
headers : {
@@ -253,7 +263,7 @@ export default class RssPlugin
253
263
? { Authorization : `Bearer ${ this . apiSecret } ` }
254
264
: { } ) ,
255
265
} ,
256
- body : JSON . stringify ( item ) ,
266
+ body : JSON . stringify ( serializedItem ) ,
257
267
} ) ;
258
268
259
269
if ( ! response . ok ) {
You can’t perform that action at this time.
0 commit comments