![Glossary Logo](/duyet/glossary-rs/raw/master/.github/logo.png)
Open-Source Glossary API Service written in Rust, powered by https://actix.rs and https://diesel.rs.
Method | Endpoint | What it does |
---|---|---|
GET | /api/v1/glossary |
Returns a dictionary of glossary with key is the first character of glossary terms. |
GET | /api/v1/glossary-popular |
Returns an array of most popular terms by likes. |
GET | /api/v1/glossary/{id} |
Return the glossary term and defintion. |
POST | /api/v1/glossary |
Create a new glossary with term and defintion . |
PUT | /api/v1/glossary/{id} |
Update a glossary. |
DELETE | /api/v1/glossary/{id} |
Delete a glossary. |
GET | /api/v1/glossary/{id}/likes |
Return an array of likes for a glossary. |
POST | /api/v1/glossary/{id}/likes |
Create a like for a glossary. |
DELETE | /api/v1/glossary/{id}/likes |
Delete a like from a glossary. |
- Rust >= 1.26
- PostgreSQL >= 9.5
Install the diesel command-line tool including the postgres feature
cargo install diesel_cli --no-default-features --features postgres
Check the contents of the .env
file.
If your database requires a password, update DATABASE_URL
to be of the form:
DATABASE_URL=postgres://username:password@localhost/glossary
Tip: on MacOS, please prefer to use https://postgres.app
Then to create and set-up the database run:
diesel database setup
Migrate database schema:
diesel migration run
To run the application execute:
cargo run
Then open in your browser: http://localhost:8080
To run the unittest, make sure to have Postgres installed in your machine.
Please export TEST_DATABASE_URL=postgres://localhost:5432
to your Postgres instance.
- On the MacOS, the easiest way is install https://postgres.app
- Otherwise, you can start Postgres by Docker Compose:
docker-compose up -d
To run the unittest:
cargo test
Deploy using docker image from https://github.com/duyet/glossary/pkgs/container/glossary
docker run -it \
-e DATABASE_URL=postgres://postgres:5432/glossary \
-p 8080:8080 \
ghcr.io/duyet/glossary:0.1.0
TBU
Build and deploy by using docker:
docker build -t glossary .
docker run -it \
-e DATABASE_URL=postgres://postgres:5432/glossary \
-p 8080:8080 \
glossary
MIT