Skip to content

Commit

Permalink
Develop (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
robatipoor authored Jun 30, 2023
1 parent 4e5e38b commit 9dc6738
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUSTfulapi
Reusable template for building REST Web Services in Rust. Uses [Actix-Web](https://actix.rs/) HTTP web framework and [SQLX](https://github.com/launchbadge/sqlx) Toolkit and [PostgreSQL](https://www.postgresql.org/)
Reusable template for building REST Web Services in Rust. Uses [Actix-Web](https://actix.rs/) HTTP web framework and [SQLX](https://github.com/launchbadge/sqlx) Toolkit and [PostgreSQL](https://www.postgresql.org/).

![License](https://img.shields.io/github/license/robatipoor/rustfulapi)
![Lines of code](https://img.shields.io/tokei/lines/github/robatipoor/rustfulapi)
Expand Down Expand Up @@ -54,8 +54,8 @@ curl -X GET http://127.0.0.1:8080/api/v1/server/health_check
```bash
cd ./docker/dev/ && ./up.sh
```
### Run tests
Some of the integration tests use docker to spin up dependencies on demand (ie a postgres db) so just be aware that docker is needed to run the tests.
### Running tests
Some of the integration tests use Docker to spin up dependencies on demand (e.g., a postgres db),so please ensure Docker is installed before running the tests.
```
./test.sh
```
Expand Down Expand Up @@ -86,11 +86,11 @@ export APP_PROFILE=prod # switch to production profile
cargo sqlx prepare --merged -- --all-features

```
### Check code formatting at commit time
### Check code formatting and typo at commit time
```
cp ./scripts/git ./.git/hooks/
cp ./scripts/git-hooks ./.git/hooks/
```
### Update ERD use [planter](https://github.com/achiku/planter)
### Update ERD (Entity-Relationship Diagram) use [planter](https://github.com/achiku/planter)
```bash
planter postgres://postgres_user:postgres_pass@localhost:5432/postgres_db\?sslmode=disable -o docs/schema.puml
```
Expand All @@ -103,7 +103,7 @@ Licensed under either of

## Contributing

Contributors are welcome, please fork and send pull requests! If you find a bug
Contributors are welcome! please fork and send pull requests, If you find a bug
or have any ideas on how to improve this project please submit an issue.

See [CONTRIBUTING.md](CONTRIBUTING.md).
2 changes: 0 additions & 2 deletions scripts/git-hook/pre-commit

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/git-hook/pre-commit-cargo-fmt

This file was deleted.

8 changes: 8 additions & 0 deletions scripts/git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
"$(git rev-parse --git-dir)/hooks/pre-commit-cargo-fmt"
fmt=$?
"$(git rev-parse --git-dir)/hooks/pre-commit-typos"
typos=$?
if [[ $fmt -ne 0 ]] || [[ $typos -ne 0 ]];then
exit 1
fi
11 changes: 11 additions & 0 deletions scripts/git-hooks/pre-commit-cargo-fmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cargo fmt -- --check
result=$?

if [[ ${result} -ne 0 ]] ; then
cat <<\EOF
There are some code style issues, run `cargo fmt && git add .` first.
EOF
exit 1
fi
11 changes: 11 additions & 0 deletions scripts/git-hooks/pre-commit-typos
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

typos
result=$?

if [[ ${result} -ne 0 ]] ; then
cat <<\EOF
There are some typo issues, run `typos --write-changes && git add .` first.
EOF
exit 1
fi

0 comments on commit 9dc6738

Please sign in to comment.