-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathserver.ts
More file actions
77 lines (73 loc) · 2.02 KB
/
server.ts
File metadata and controls
77 lines (73 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { setupServer } from 'msw/node';
import { http, HttpResponse } from 'msw';
export const server = setupServer(
http.get('/api/v1', () => {
return HttpResponse.json({
success: true,
data: {
api: {
name: 'html2rss-web API',
description: 'RESTful API for converting websites to RSS feeds',
openapi_url: 'http://example.test/openapi.yaml',
},
instance: {
feed_creation: {
enabled: true,
access_token_required: true,
},
},
},
});
}),
http.get('/api/v1/strategies', () => {
return HttpResponse.json({
success: true,
data: {
strategies: [
{
id: 'ssrf_filter',
name: 'ssrf_filter',
display_name: 'Standard (recommended)',
},
{
id: 'browserless',
name: 'browserless',
display_name: 'JavaScript pages',
},
],
},
meta: { total: 2 },
});
})
);
export interface FeedResponseOverrides {
id?: string;
name?: string;
url?: string;
strategy?: string;
feed_token?: string;
public_url?: string;
json_public_url?: string;
created_at?: string;
updated_at?: string;
}
export function buildFeedResponse(overrides: FeedResponseOverrides = {}) {
const timestamp = overrides.created_at ?? new Date('2024-01-01T00:00:00Z').toISOString();
return {
success: true,
data: {
feed: {
id: overrides.id ?? 'feed-123',
name: overrides.name ?? 'Example Feed',
url: overrides.url ?? 'https://example.com/articles',
strategy: overrides.strategy ?? 'ssrf_filter',
feed_token: overrides.feed_token ?? 'example-token',
public_url: overrides.public_url ?? '/api/v1/feeds/example-token',
json_public_url: overrides.json_public_url ?? '/api/v1/feeds/example-token.json',
created_at: timestamp,
updated_at: overrides.updated_at ?? timestamp,
},
},
meta: { created: true },
};
}