From 2b36f868e7be1bc587f930807f463fd955d2506a Mon Sep 17 00:00:00 2001
From: Alexander Roidl <34438048+alexanderroidl@users.noreply.github.com>
Date: Sat, 26 Jul 2025 20:42:58 +0200
Subject: [PATCH] Project-wide linting and formatting (#150)
* chore: configure project-wide linting and formatting
* chore: run lint autofix and formatter
---
.babelrc | 6 +-
.eslintignore | 3 +
.eslintrc.cjs | 1 -
.github/ISSUE_TEMPLATE/bug_report.md | 2 +-
.github/ISSUE_TEMPLATE/feature_request.md | 1 -
.github/workflows/stales.yml | 16 +--
.prettierignore | 6 +
CHANGELOG.md | 26 +++-
CONTRIBUTING.md | 57 ++++----
README.md | 53 +++++---
conf/config.json | 8 +-
docker-compose.yml | 3 +-
index.html | 27 ++--
lib/api/routes/demoRouter.js | 4 +-
lib/api/routes/generalSettingsRoute.js | 8 +-
lib/api/routes/loginRoute.js | 7 +-
lib/api/routes/notificationAdapterRouter.js | 2 +-
lib/api/routes/providerRouter.js | 2 +-
lib/api/routes/userRoute.js | 13 +-
lib/defaultConfig.js | 12 +-
lib/notification/adapter/console.md | 2 +-
lib/notification/adapter/mailJet.md | 10 +-
lib/notification/adapter/mattermost.md | 4 +-
lib/notification/adapter/ntfy.md | 4 +-
lib/notification/adapter/pushover.js | 125 +++++++++---------
lib/notification/adapter/pushover.md | 2 +-
lib/notification/adapter/sendGrid.md | 5 +-
lib/notification/adapter/slack.md | 7 +-
lib/notification/adapter/sqlite.md | 6 +-
lib/notification/adapter/telegram.js | 12 +-
lib/notification/adapter/telegram.md | 15 +--
lib/services/tracking/Tracker.js | 116 ++++++++--------
lib/utils.js | 116 ++++++++--------
package.json | 6 +-
reverse-engineered-immoscout.md | 36 +++--
test/queryStringMutator/testData.json | 2 +-
test/services/immoscout/testdata.json | 2 +-
ui/src/App.less | 13 +-
ui/src/Index.less | 7 +-
ui/src/components/logo/Logo.less | 4 +-
.../components/placeholder/Placeholder.less | 13 +-
ui/src/components/segment/SegmentParts.less | 2 +-
ui/src/components/tracking/TrackingModal.less | 4 +-
ui/src/services/developmentMode.js | 8 +-
ui/src/services/xhr.js | 2 +-
.../generalSettings/GeneralSettings.less | 3 +-
ui/src/views/jobs/Jobs.less | 6 +-
ui/src/views/jobs/mutation/JobMutation.less | 4 +-
.../NotificationAdapterMutator.less | 8 +-
.../components/provider/ProviderMutator.less | 6 +-
ui/src/views/user/Users.less | 6 +-
ui/src/views/user/mutation/UserMutator.less | 4 +-
52 files changed, 435 insertions(+), 382 deletions(-)
create mode 100644 .eslintignore
create mode 100644 .prettierignore
diff --git a/.babelrc b/.babelrc
index b67a68f..103732f 100644
--- a/.babelrc
+++ b/.babelrc
@@ -3,9 +3,7 @@
[
"@babel/preset-env",
{
- "exclude": [
- "transform-regenerator"
- ]
+ "exclude": ["transform-regenerator"]
}
],
[
@@ -15,4 +13,4 @@
}
]
]
-}
\ No newline at end of file
+}
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..86c15b9
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,3 @@
+/ui/public
+/db/
+/conf/
\ No newline at end of file
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 2bbb296..6878f30 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -277,6 +277,5 @@ module.exports = {
// Prevent passing of children as props
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
'react/no-children-prop': 'warn',
-
},
};
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 8c84cd0..f1ce96a 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -4,7 +4,6 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
-
---
**Describe the bug**
@@ -12,6 +11,7 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
+
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index bbcbbe7..2f28cea 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
-
---
**Is your feature request related to a problem? Please describe.**
diff --git a/.github/workflows/stales.yml b/.github/workflows/stales.yml
index bb48b54..0399d78 100644
--- a/.github/workflows/stales.yml
+++ b/.github/workflows/stales.yml
@@ -2,7 +2,7 @@ name: Close stale issues and PRs
on:
schedule:
- - cron: '0 0 * * *' # Daily
+ - cron: '0 0 * * *' # Daily
jobs:
stale:
@@ -12,10 +12,10 @@ jobs:
with:
days-before-stale: 30
days-before-close: 7
- stale-issue-message: "This issue has been automatically marked as stale due to inactivity."
- stale-pr-message: "This PR has been automatically marked as stale due to inactivity."
- close-issue-message: "Closing this issue due to prolonged inactivity."
- close-pr-message: "Closing this PR due to prolonged inactivity."
- exempt-issue-labels: "keep-open"
- exempt-pr-labels: "keep-open"
- only: "pulls"
\ No newline at end of file
+ stale-issue-message: 'This issue has been automatically marked as stale due to inactivity.'
+ stale-pr-message: 'This PR has been automatically marked as stale due to inactivity.'
+ close-issue-message: 'Closing this issue due to prolonged inactivity.'
+ close-pr-message: 'Closing this PR due to prolonged inactivity.'
+ exempt-issue-labels: 'keep-open'
+ exempt-pr-labels: 'keep-open'
+ only: 'pulls'
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..57e7bff
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,6 @@
+/ui/public
+/db/
+/conf/
+
+# TODO re-write from scratch or fix all html structure issues
+/lib/notification/emailTemplate/template.hbs
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2785bd0..7fbc52e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,34 +1,42 @@
Newer release changelog see https://github.com/orangecoding/fredy/releases
-------------
+---
###### [V5.5.0]
+
- Upgrading dependencies
- fixing provider
-- allow multiple instances of 1 provider
-- __BREAKING__: Minimum node version is now 16
+- allow multiple instances of 1 provider
+- **BREAKING**: Minimum node version is now 16
###### [V5.4.6]
+
- Adding Instana node.js monitoring
--
+-
+
###### [V5.4.5]
-- Adding Instana node.js monitoring
+
+- Adding Instana node.js monitoring
###### [V5.4.4]
+
- Add support for Immo Südwest Presse (immo.swp.de)
- Telegram: Use job name instead of ID and link in title
- Fix race condition if user ID is in session but not in user store
- Allow visiting the original provider URL
###### [V5.4.3]
+
- re-writing readme
- improving docker build
- using github's actions to build docker and test automatically
###### [V5.4.2]
+
- Fixing prod build
###### [V5.4.1]
+
- Upgrading dependencies
- Provider urls are now automagically been changed to include the correct sort order for search results
@@ -39,36 +47,44 @@ results, thus cannot report them. This release fixes it by adding the necessary
```
###### [V5.3.0]
+
- Upgrading dependencies
- It's now possible to send mails to multiple receiver using comma separation for MailJet & Sendgrid
- Fixing Immowelt scraping
###### [V5.2.0]
+
- Upgrading dependencies
- Adding new similarity check layer (Duplicates are being removed now)
- Adding paging for search results
###### [V5.1.0]
+
- Upgrading dependencies
- NodeJS 12.13 is now the minimum supported version
- Adding general settings as new configuration page to ui
- Adding new feature working hours
###### [V5.0.0]
+
- Upgrading dependencies
- NodeJS 12 is now the minimum supported version
###### [V4.0.0]
+
Bringing back Immoscout :tada:
###### [V3.0.0]
+
This is basically a re-write, your old config file will not be compatible anymore. Please re-created your search jobs
on the new ui and use the values from your previous config file if needed.
+
```
- We're getting rid of manual config changes, Fredy, now ships with a UI so that it's easy for you to create and edit jobs
```
###### [V2.0.0]
+
```
- Fredy can now run multiple search job on one instance
- Changed lot's of the structure of Fredy to make this happen
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f87c221..594b50e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,8 +2,8 @@
If you want to contribute, please make sure you've executed the tests.
-
### How to write new provider?
+
- create the provider filer under `/lib/provider`
- create a test under /test and make sure it is running successfully
@@ -13,7 +13,7 @@ let appliedBlackList = [];
//normalize incoming values
function normalize(o) {
const id = parseInt(o.id.substring(o.id.indexOf('_') + 1, o.id.length));
-
+
return Object.assign(o, { id });
}
@@ -27,7 +27,7 @@ function applyBlacklist(o) {
const config = {
url: null,
- //this is the container wrapping the search listings
+ //this is the container wrapping the search listings
crawlContainer: '#result-list-stage .item',
crawlFields: {
id: '@id',
@@ -49,7 +49,7 @@ exports.init = (sourceConfig, blacklist) => {
appliedBlackList = blacklist || [];
};
-//ths
+//ths
exports.metaInformation = {
name: 'your provider name',
baseUrl: 'https://www.yourprovider.de/',
@@ -57,11 +57,10 @@ exports.metaInformation = {
};
exports.config = config;
-
```
-
### How to write new notification adapter?
+
- create the provider filer under `/lib/notification/adapter`
- create a description of the provider under `/lib/notification/adapter/*.md`. Make sure the name of the md file is equal to the notification adapter
@@ -72,43 +71,43 @@ const Slack = require('slack');
const msg = Slack.chat.postMessage;
const { markdown2Html } = require('../../services/markdown');
-
//as a parameter, you will always get the serviceName, newListings and all the values, that
//you have defined exports.config.fields. (This is being used for rendering in the frontend)
exports.send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
- const { token, channel } = notificationConfig.find((adapter) => adapter.id === 'slack').fields;
- return newListings.map((payload) => {
- //tho whatever needs to be done to send the data to the receiver, make sure the format is human readable
- });
+ const { token, channel } = notificationConfig.find((adapter) => adapter.id === 'slack').fields;
+ return newListings.map((payload) => {
+ //tho whatever needs to be done to send the data to the receiver, make sure the format is human readable
+ });
};
exports.config = {
- id: __filename.slice(__dirname.length + 1, -3),
- name: 'someUniqueName, used in the frontend',
- //this readme is rendered in the frontend to explain how to use this
- readme: markdown2Html('lib/notification/adapter/slack.md'),
- description: 'Some description text rendered on the notification page',
- fields: {
- token: {
- //type can be text/number/boolean
- type: 'text',
- label: 'Token',
- description: 'The token needed to send notifications to slack.',
- },
- channel: {
- type: 'channel',
- label: 'Channel',
- description: 'The channel where fredy should send notifications to.',
- },
+ id: __filename.slice(__dirname.length + 1, -3),
+ name: 'someUniqueName, used in the frontend',
+ //this readme is rendered in the frontend to explain how to use this
+ readme: markdown2Html('lib/notification/adapter/slack.md'),
+ description: 'Some description text rendered on the notification page',
+ fields: {
+ token: {
+ //type can be text/number/boolean
+ type: 'text',
+ label: 'Token',
+ description: 'The token needed to send notifications to slack.',
},
+ channel: {
+ type: 'channel',
+ label: 'Channel',
+ description: 'The channel where fredy should send notifications to.',
+ },
+ },
};
-
```
#### Running Tests
+
If you've written a new provider you are an awesome person. If you now write tests for it, you are even more awesome. And who doesn't want to be more awesome, right?
#### Codestyle
+
I'm using ESLint to maintain quote style and quality. Do not skip it...
##### To-do before merging:
diff --git a/README.md b/README.md
index 4d5fd24..8e0d350 100755
--- a/README.md
+++ b/README.md
@@ -1,14 +1,15 @@
-
+
- [](https://github.com/orangecoding/fredy/actions/workflows/docker.yml) 
+ [](https://github.com/orangecoding/fredy/actions/workflows/docker.yml) 
Searching an apartment in Germany can be a frustrating task. Not any longer though, as _Fredy_ will take over and will only notify you once new listings have been found that match your requirements.
-_Fredy_ scrapes multiple services (Immonet, Immowelt etc.) and send new listings to you once they become available. The list of available services can easily be extended. For your convenience, _Fredy_ has a UI to help you configure your search jobs.
+_Fredy_ scrapes multiple services (Immonet, Immowelt etc.) and send new listings to you once they become available. The list of available services can easily be extended. For your convenience, _Fredy_ has a UI to help you configure your search jobs.
If _Fredy_ finds matching results, it will send them to you via Slack, Email, Telegram etc. (More adapters can be configured.) As _Fredy_ stores the listings it has found, new results will not be sent to you twice (and as a side-effect, _Fredy_ can show some statistics). Furthermore, _Fredy_ checks duplicates per scraping so that the same listings are not being sent twice or more when posted on various platforms (which happens more often than one might think).
-# Sponsorship [](https://github.com/sponsors/orangecoding)
+# Sponsorship [](https://github.com/sponsors/orangecoding)
+
If you like my work, consider becoming a sponsor. I'm not expecting anybody to pay for _Fredy_ or any other Open Source Project I'm maintaining, however keep in mind, I'm doing all of this in my spare time :) Thanks.
[](https://jb.gg/OpenSourceSupport)
@@ -16,17 +17,20 @@ If you like my work, consider becoming a sponsor. I'm not expecting anybody to p
_Fredy_ is supported by JetBrains under Open Source Support Program
## Demo
+
If you want to try out _Fredy_, you can access the demo version [here](https://fredy.orange-coding.net) 🤘
-## Usage
+## Usage
- Make sure to use Node.js 20 or above
- Run the following commands:
+
```ssh
yarn
yarn run start:backend
yarn run start:frontend
```
+
_Fredy_ will start with the default port, set to `9998`. You can access _Fredy_ by opening your browser at `http://localhost:9998`. The default login is `admin`, both for username and password. You should change the password as soon as possible when you plan to run Fredy on a server.
@@ -38,62 +42,79 @@ _Fredy_ will start with the default port, set to `9998`. You can access _Fredy_
## Understanding the fundamentals + There are 3 important parts in Fredy, that you need to understand to leverage the full power of _Fredy_. #### Provider + _Fredy_ supports multiple services. Immonet, Immowelt and Ebay are just a few examples. Those services are called providers within _Fredy_. When creating a new job, you can choose one or more providers. A provider contains the URL that points to the search results for the respective service. If you go to immonet.de and search for something, the displayed URL in the browser is what the provider needs to do its magic. **It is important that you order the search results by date, so that _Fredy_ always picks the latest results first!** #### Adapter + _Fredy_ supports multiple adapters, such as Slack, SendGrid, Telegram etc. A search job can have as many adapters as supported by _Fredy_. Each adapter needs different configuration values, which you have to provide when using them. An adapter dictates how the frontend renders by telling the frontend what information it needs in order to send listings to the user. #### Jobs + A Job wraps adapters and providers. _Fredy_ runs the configured jobs in a specific interval (can be configured in `/conf/config.json`). ## Creating your first job + To create your first job, click on the button "Create New Job" on the job table. The job creation dialog should be self-explanatory, however there is one important thing. When configuring providers, before copying the URL from your browser, make sure that you have sorted the results by date to make sure _Fredy_ always picks the latest results first. ## User management + As an administrator, you can create, edit and remove users from _Fredy_. Be careful, each job is connected to the user that has created the job. If you remove the user, their jobs will also be removed. # Development ### Running Fredy in development mode + Start the backend with: + ```shell yarn run start:backend:dev ``` + For the frontend, run: + ```shell yarn run start:frontend:dev ``` + You should now be able to access _Fredy_ from your browser. Check your Terminal to see what port the frontend is running on. ### Running Tests + To run the tests, run + ```shell yarn run test ``` # Architecture - + + ### Immoscout + Immoscout has implemented advanced bot detection. In order to work around this, we are using a reversed engineered version of their mobile api. See [Immoscout Reverse Engineering Documentation](https://github.com/orangecoding/fredy/blob/master/reverse-engineered-immoscout.md) # Analytics -Fredy is completely free (and will always remain free). However, it would be a huge help if you’d allow me to collect some analytical data. -Before you freak out, let me explain... -If you agree, Fredy will send a ping to my Mixpanel project each time it runs. + +Fredy is completely free (and will always remain free). However, it would be a huge help if you’d allow me to collect some analytical data. +Before you freak out, let me explain... +If you agree, Fredy will send a ping to my Mixpanel project each time it runs. The data includes: names of active adapters/providers, OS, architecture, Node version, and language. The information is entirely anonymous and helps me understand which adapters/providers are most frequently used. **Thanks**🤘 -# Docker -Use the Dockerfile in this repository to build an image. +# Docker -Example: `docker build -t fredy/fredy /path/to/your/Dockerfile` +Use the Dockerfile in this repository to build an image. + +Example: `docker build -t fredy/fredy /path/to/your/Dockerfile` Or use docker-compose: @@ -103,17 +124,18 @@ Or use the container that will be built automatically. `docker pull ghcr.io/orangecoding/fredy:master` -## Create & run a container +## Create & run a container Put your config.json into a path of your choice, such as `/path/to/your/conf/`. Example: `docker create --name fredy -v /path/to/your/conf/:/conf -p 9998:9998 fredy/fredy` -## Logs +## Logs -You can browse the logs with `docker logs fredy -f`. +You can browse the logs with `docker logs fredy -f`. ### 👐 Contributing + Thanks to all the people who already contributed! @@ -122,7 +144,6 @@ Thanks to all the people who already contributed! See [Contributing](https://github.com/orangecoding/fredy/blob/master/CONTRIBUTING.md) - ## Star History [](https://www.star-history.com/#orangecoding/fredy&Date) diff --git a/conf/config.json b/conf/config.json index e8c9521..b0003aa 100755 --- a/conf/config.json +++ b/conf/config.json @@ -1 +1,7 @@ -{"interval":"60","port":9998,"workingHours":{"from":"","to":""},"demoMode":false,"analyticsEnabled":null} \ No newline at end of file +{ + "interval": "60", + "port": 9998, + "workingHours": { "from": "", "to": "" }, + "demoMode": false, + "analyticsEnabled": null +} diff --git a/docker-compose.yml b/docker-compose.yml index f6d96f1..0061893 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: fredy: container_name: fredy @@ -12,5 +11,5 @@ services: - ./conf:/conf - ./db:/db ports: - - 9998:9998 + - 9998:9998 restart: unless-stopped diff --git a/index.html b/index.html index 56d5608..662d1a1 100644 --- a/index.html +++ b/index.html @@ -1,16 +1,17 @@ - + - - - + + +