2023-05-10 04:15:41 +00:00
|
|
|
# crawlnicle
|
|
|
|
|
|
|
|
My personalized news and blog aggregator. Taking back control over the
|
|
|
|
algorithm. Pining for the days of Google Reader. An excuse to write more Rust.
|
|
|
|
|
2023-06-28 05:20:04 +00:00
|
|
|
## Development Instructions
|
2023-05-10 04:15:41 +00:00
|
|
|
|
2023-06-28 05:20:04 +00:00
|
|
|
### Prerequisites
|
2023-05-10 04:15:41 +00:00
|
|
|
|
2023-06-28 05:20:04 +00:00
|
|
|
Install these requirements to get started developing crawlnicle.
|
2023-05-10 04:15:41 +00:00
|
|
|
|
2024-05-09 04:32:08 +00:00
|
|
|
- [rust](https://www.rust-lang.org/)
|
|
|
|
- [postgres](https://www.postgresql.org/)
|
|
|
|
- [redis](https://redis.io/)
|
|
|
|
- [sqlx-cli](https://crates.io/crates/sqlx-cli)
|
|
|
|
|
|
|
|
- Only postgres needed. Install with:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cargo install sqlx-cli --no-default-features --features native-tls,postgres
|
|
|
|
```
|
|
|
|
|
|
|
|
- [just](https://github.com/casey/just#installation)
|
|
|
|
- [bun](https://bun.sh)
|
|
|
|
- An [SMTP server for sending
|
|
|
|
emails](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol) (put
|
|
|
|
configuration in the `.env` file)
|
|
|
|
- (optional) [cargo-watch](https://github.com/watchexec/cargo-watch#install) for
|
|
|
|
auto-recompiling the server in development
|
|
|
|
- (optional) [mold](https://github.com/rui314/mold#installation) for faster
|
|
|
|
builds
|
2023-06-28 05:20:04 +00:00
|
|
|
|
|
|
|
### First-time setup
|
|
|
|
|
|
|
|
1. Create postgres user and database:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
createuser crawlnicle
|
|
|
|
createdb crawlnicle
|
|
|
|
sudo -u postgres -i psql
|
|
|
|
postgres=# ALTER DATABASE crawlnicle OWNER TO crawlnicle;
|
2023-10-13 12:07:38 +00:00
|
|
|
postgres=# ALTER USER crawlnicle CREATEDB;
|
2023-06-28 05:20:04 +00:00
|
|
|
\password crawlnicle
|
|
|
|
|
|
|
|
# Or, on Windows in PowerShell:
|
|
|
|
|
|
|
|
& 'C:\Program Files\PostgreSQL\13\bin\createuser.exe' -U postgres crawlnicle
|
|
|
|
& 'C:\Program Files\PostgreSQL\13\bin\createdb.exe' -U postgres crawlnicle
|
|
|
|
& 'C:\Program Files\PostgreSQL\13\bin\psql.exe' -U postgres
|
|
|
|
postgres=# ALTER DATABASE crawlnicle OWNER TO crawlnicle;
|
2023-10-17 04:15:44 +00:00
|
|
|
postgres=# ALTER USER crawlnicle CREATEDB;
|
2023-06-28 05:20:04 +00:00
|
|
|
\password crawlnicle
|
|
|
|
```
|
|
|
|
|
|
|
|
1. Save password somewhere safe and then and add a `.env` file to the project
|
2023-05-10 04:15:41 +00:00
|
|
|
directory with the contents:
|
|
|
|
|
2023-06-28 05:20:04 +00:00
|
|
|
```env
|
|
|
|
RUST_LOG=crawlnicle=debug,cli=debug,lib=debug,tower_http=debug,sqlx=debug
|
|
|
|
HOST=127.0.0.1
|
|
|
|
PORT=3000
|
2023-09-29 03:53:46 +00:00
|
|
|
PUBLIC_URL=http://localhost:3000
|
2023-06-28 05:20:04 +00:00
|
|
|
DATABASE_URL=postgresql://crawlnicle:<password>@localhost/crawlnicle
|
|
|
|
DATABASE_MAX_CONNECTIONS=5
|
2023-09-26 05:47:50 +00:00
|
|
|
REDIS_URL=redis://localhost
|
2023-06-28 05:20:04 +00:00
|
|
|
TITLE=crawlnicle
|
|
|
|
MAX_MEM_LOG_SIZE=1000000
|
2023-07-06 03:45:49 +00:00
|
|
|
CONTENT_DIR=./content
|
2023-09-28 03:11:52 +00:00
|
|
|
SMTP_SERVER=smtp.gmail.com
|
|
|
|
SMTP_USER=user
|
|
|
|
SMTP_PASSWORD=password
|
2023-09-29 03:53:46 +00:00
|
|
|
EMAIL_FROM="crawlnicle <no-reply@mail.crawlnicle.com>"
|
2024-05-09 04:32:08 +00:00
|
|
|
SESSION_SECRET=64-bytes-of-base64-encoded-secret
|
2023-10-17 04:15:44 +00:00
|
|
|
IP_SOURCE=ConnectInfo
|
2023-06-28 05:20:04 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
1. Run `just migrate` (or `sqlx migrate run`) which will run all the database
|
|
|
|
migrations.
|
|
|
|
|
|
|
|
### Running in Development
|
|
|
|
|
|
|
|
Run `just watch` to build and run the server while watching the source-files for
|
|
|
|
changes and triggering a recompilation when modifications are made.
|
|
|
|
|
|
|
|
The server also triggers the browser to reload the page when the server binary
|
|
|
|
is updated and the server is restarted.
|
|
|
|
|
|
|
|
It also separately watches the files in `frontend/` which will trigger a
|
|
|
|
transpilation with `bun` and then rebuild the server binary so that it includes
|
|
|
|
the new JS bundle names.
|
|
|
|
|
2023-06-29 04:00:26 +00:00
|
|
|
Alternatively, you can just run `cargo run` after building the frontend
|
|
|
|
JavaScript with `just build-dev-frontend`.
|
2023-06-28 05:20:04 +00:00
|
|
|
|
|
|
|
### Building for Production
|
|
|
|
|
|
|
|
You can also build the binary in release mode for running in production with the
|
2023-06-29 04:00:26 +00:00
|
|
|
`just build` command. This will first build the minified frontend JavaScript
|
|
|
|
(`just build-frontend`) and then build the rust binary with `cargo build
|
|
|
|
--release`.
|
2023-05-10 04:15:41 +00:00
|
|
|
|
|
|
|
## Using the CLI
|
|
|
|
|
|
|
|
This project also comes with a CLI binary which allows you to manipulate the
|
|
|
|
database directly without needing to go through the REST API server. Run
|
2023-06-28 05:20:04 +00:00
|
|
|
`cli --help` to see all of the available commands.
|