https://github.com/junekimdev/stockinfo-backend
Backend for Stockinfo website
https://github.com/junekimdev/stockinfo-backend
Last synced: 5 months ago
JSON representation
Backend for Stockinfo website
- Host: GitHub
- URL: https://github.com/junekimdev/stockinfo-backend
- Owner: junekimdev
- License: other
- Created: 2024-05-03T09:29:29.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-12-11T10:19:02.000Z (7 months ago)
- Last Synced: 2025-12-12T02:37:29.417Z (6 months ago)
- Language: Rust
- Size: 849 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stockinfo Backend

[](https://github.com/junekimdev/stockinfo-backend/actions/workflows/docker-publish.yaml)
## Getting Started
### Prerequisite
- Install latest `Rust`
```shell
# for linux
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh
rustup update
rustc --version
```
- Install `Docker`
- Install `Make`
- Install `OpenSSL`
- for Windows:
- Use `vcpkg` to install `OpenSSL`
- Set `OPENSSL_DIR` environment variable to its installed path
- or set `OPENSSL_LIB_DIR` and `OPENSSL_INCLUDE_DIR` environment variables to its installed path
- Set the `VCPKGRS_DYNAMIC` environment variable to `1` to instruct the `openssl-sys` crate to use dynamic linking
- for Debian and Ubuntu:
- `sudo apt-get install pkg-config libssl-dev`
- for Alpine Linux:
- `apk add pkgconf openssl-dev`
- for Arch Linux:
- `sudo pacman -S pkgconf openssl`
- for macOS
- Use Homebrew: `brew install openssl@3`
- or use MacPorts: `sudo port install openssl`
- or use pkgsrc: `sudo pkgin install openssl`
### Prep env and config
- Add a file `.env` that includes environmental variables
Example:
```shell
POSTGRES_USER=stockinfo
POSTGRES_DB=stockinfo
POSTGRES_PASSWORD=super-secret-password
POSTGRES_INITDB_ARGS="--lc-collate=C --lc-ctype=en_US.UTF-8"
```
- Add a file `production.toml` under `/config` by modifying `default.toml` with proper values
### Build
- Build docker image by running `make` in your terminal
- or run `cargo build`
### Initial DB Build
```shell
curl -X POST -d {} /v1/companies
curl -X POST -d {} /v1/dart/code
curl -X POST -d {} /v1/tickers
```
### Edit crontab
- Open crontab editor: `crontab -e`
- Schedule API executions for cleaning process
```shell
0 0 * * * curl -X DELETE /v1/prices &> /dev/null
0 5 * * * curl -X DELETE /v1/prices_us &> /dev/null
0 18 * * 6 curl -X POST -d {} /v1/companies &> /dev/null
30 18 * * 6 curl -X POST -d {} /v1/dart/code &> /dev/null
0 19 * * 6 curl -X POST -d {} /v1/tickers &> /dev/null
```
## Authors
- **June Kim** - _Initial work_ - [Github](https://github.com/junekimdev)
## License
No license is given by the author. All rights are reserved.