Skip to content

Commit 3cd0291

Browse files
committed
.
Signed-off-by: Gil Desmarais <git@desmarais.de>
1 parent 4583168 commit 3cd0291

File tree

8 files changed

+41
-77
lines changed

8 files changed

+41
-77
lines changed

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ The in-repo docs live under `frontend/src/content/docs/` and are published by As
2424

2525
## REST API Snapshot
2626
```bash
27-
# List feeds available to the token
27+
# List available strategies
2828
curl -H "Authorization: Bearer <token>" \
29-
"https://your-domain.com/api/v1/feeds"
29+
"https://your-domain.com/api/v1/strategies"
3030

3131
# Create a feed and capture the signed public URL
3232
curl -X POST "https://your-domain.com/api/v1/feeds" \
@@ -60,37 +60,37 @@ The Ruby server continues to serve the production build while Astro runs with ho
6060

6161
## Make Targets
6262

63-
| Command | Purpose |
64-
| --- | --- |
65-
| `make help` | List available shortcuts. |
66-
| `make setup` | Install Ruby and Node dependencies. |
67-
| `make dev` | Run Ruby (port 3000) and Astro (port 4321) dev servers. |
68-
| `make dev-ruby` | Start only the Ruby server. |
69-
| `make dev-frontend` | Start only the Astro dev server. |
70-
| `make test` | Run Ruby and frontend test suites. |
71-
| `make test-ruby` | Run Ruby specs. |
72-
| `make test-frontend` | Run frontend unit and contract tests. |
73-
| `make lint` | Run all linters. |
74-
| `make lintfix` | Auto-fix lint warnings where possible. |
75-
| `make clean` | Remove build artefacts. |
63+
| Command | Purpose |
64+
| -------------------- | ------------------------------------------------------- |
65+
| `make help` | List available shortcuts. |
66+
| `make setup` | Install Ruby and Node dependencies. |
67+
| `make dev` | Run Ruby (port 3000) and Astro (port 4321) dev servers. |
68+
| `make dev-ruby` | Start only the Ruby server. |
69+
| `make dev-frontend` | Start only the Astro dev server. |
70+
| `make test` | Run Ruby and frontend test suites. |
71+
| `make test-ruby` | Run Ruby specs. |
72+
| `make test-frontend` | Run frontend unit and contract tests. |
73+
| `make lint` | Run all linters. |
74+
| `make lintfix` | Auto-fix lint warnings where possible. |
75+
| `make clean` | Remove build artefacts. |
7676

7777
## Frontend npm Scripts
7878

79-
| Command | Purpose |
80-
| --- | --- |
81-
| `npm run dev` | Astro dev server with hot reload. |
82-
| `npm run build` | Production build. |
83-
| `npm run test:run` | Unit tests (Vitest). |
84-
| `npm run test:contract` | Contract tests with MSW. |
79+
| Command | Purpose |
80+
| ----------------------- | --------------------------------- |
81+
| `npm run dev` | Astro dev server with hot reload. |
82+
| `npm run build` | Production build. |
83+
| `npm run test:run` | Unit tests (Vitest). |
84+
| `npm run test:contract` | Contract tests with MSW. |
8585

8686
## Testing Strategy
8787

88-
| Layer | Tooling | Focus |
89-
| --- | --- | --- |
90-
| Ruby API | RSpec + Rack::Test | Feed creation, retrieval, auth paths. |
91-
| Frontend unit | Vitest + Testing Library | Component rendering and hooks with mocked fetch. |
92-
| Frontend contract | Vitest + MSW | End-to-end fetch flows against mocked API responses. |
93-
| Docker smoke | RSpec (`:docker`) | Net::HTTP probes against the containerised service. |
88+
| Layer | Tooling | Focus |
89+
| ----------------- | ------------------------ | ---------------------------------------------------- |
90+
| Ruby API | RSpec + Rack::Test | Feed creation, retrieval, auth paths. |
91+
| Frontend unit | Vitest + Testing Library | Component rendering and hooks with mocked fetch. |
92+
| Frontend contract | Vitest + MSW | End-to-end fetch flows against mocked API responses. |
93+
| Docker smoke | RSpec (`:docker`) | Net::HTTP probes against the containerised service. |
9494

9595
## Contributing
9696

app/api/v1/feeds.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ module Web
1717
module Api
1818
module V1
1919
# RESTful API v1 for feeds
20-
module Feeds
20+
module Feeds # rubocop:disable Metrics/ModuleLength
2121
DEFAULT_TTL_SECONDS = 3600 # 1 hour
2222

23-
class << self
23+
class << self # rubocop:disable Metrics/ClassLength
2424
def show(request, token)
2525
ensure_auto_source_enabled!
2626

app/feeds.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,9 @@
88
module Html2rss
99
module Web
1010
##
11-
# Feeds functionality for listing and generating RSS feeds
11+
# Feeds functionality for generating RSS feeds
1212
module Feeds
1313
class << self
14-
def list_feeds
15-
LocalConfig.feed_names.map do |name|
16-
{
17-
id: name.to_s,
18-
name: name.to_s,
19-
description: "RSS feed for #{name}",
20-
public_url: "/#{name}"
21-
}
22-
end
23-
end
24-
2514
def generate_feed(feed_name, params = {})
2615
config = LocalConfig.find(feed_name)
2716
config[:params] = (config[:params] || {}).merge(params) if params.any?

app/local_config.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ def global
3636
yaml.reject { |key| key == :feeds }
3737
end
3838

39-
##
40-
# @return [Array<Symbol>] names of locally available feeds
41-
def feed_names
42-
feeds.keys
43-
end
44-
4539
##
4640
# @return [Hash<Symbol, Any>]
4741
def yaml

app/url_validator.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,6 @@ def url_allowed?(account, url)
3232
end
3333
end
3434

35-
# @param url [String]
36-
# @param patterns [Array<String>]
37-
# @return [Boolean]
38-
def url_matches_patterns?(url, patterns)
39-
return false unless (normalized_url = normalize_url(url))
40-
41-
Array(patterns).any? do |pattern|
42-
wildcard?(pattern) ? match_wildcard?(pattern, normalized_url) : match_exact?(pattern, normalized_url)
43-
end
44-
end
45-
46-
# @param url [String]
47-
# @param pattern [String]
48-
# @return [Boolean]
49-
def url_matches_pattern?(url, pattern)
50-
return false unless (normalized_url = normalize_url(url))
51-
52-
wildcard?(pattern) ? match_wildcard?(pattern, normalized_url) : match_exact?(pattern, normalized_url)
53-
end
54-
5535
private
5636

5737
def match_exact?(pattern, normalized_url)

frontend/src/components/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function App() {
4343

4444
try {
4545
await login(authFormData.username, authFormData.token);
46-
} catch (error) { }
46+
} catch (error) {}
4747
};
4848

4949
const handleFeedSubmit = async (event: Event) => {
@@ -53,7 +53,7 @@ export function App() {
5353

5454
try {
5555
await convertFeed(feedFormData.url, feedFormData.strategy, token || '');
56-
} catch (error) { }
56+
} catch (error) {}
5757
};
5858

5959
const handleShowAuth = () => {
@@ -70,7 +70,7 @@ export function App() {
7070
try {
7171
const demoStrategy = strategies.length > 0 ? strategies[0].id : 'ssrf_filter';
7272
await convertFeed(url, demoStrategy, 'self-host-for-full-access');
73-
} catch (error) { }
73+
} catch (error) {}
7474
};
7575

7676
const showResultExperience = Boolean(result);

frontend/src/content/docs/api/v1.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ https://your-domain.com/api/v1
1818
Send a Bearer token in the `Authorization` header unless stated otherwise.
1919

2020
```bash
21-
curl -H "Authorization: Bearer <token>" https://your-domain.com/api/v1/feeds
21+
curl -H "Authorization: Bearer <token>" https://your-domain.com/api/v1/strategies
2222
```
2323

2424
## Response Envelope
@@ -38,10 +38,6 @@ Every JSON response returns `success`, `data`, and `meta` keys. Errors replace `
3838

3939
## Feeds
4040

41-
### GET /feeds
42-
43-
Returns the feeds the current token can access.
44-
4541
### POST /feeds
4642

4743
Creates a feed. Provide the source URL, a human-readable name, and an optional strategy.

spec/html2rss/web/app_integration_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@
4242
)
4343
allow(Html2rss::Web::AccountManager).to receive(:get_account_by_username).and_return(account)
4444
allow(Html2rss::Web::UrlValidator).to receive(:url_allowed?).and_return(true)
45-
allow(Html2rss::Web::AutoSource).to receive_messages(enabled?: true,
46-
generate_feed_content: '<rss version="2.0"></rss>')
45+
feed_channel = instance_double('Html2rss::FeedChannel', ttl: 10)
46+
feed_object = instance_double('Html2rss::Feed', channel: feed_channel)
47+
48+
allow(Html2rss::Web::AutoSource).to receive(:enabled?).and_return(true)
49+
allow(Html2rss::Web::AutoSource).to receive(:generate_feed_object).and_return(feed_object)
50+
allow(Html2rss::Web::FeedGenerator).to receive(:process_feed_content)
51+
.and_return('<rss version="2.0"></rss>')
4752
end
4853

4954
describe 'GET /api/v1/feeds/:token' do # rubocop:disable RSpec/MultipleMemoizedHelpers

0 commit comments

Comments
 (0)