{"id":22260970,"url":"https://github.com/obaraelijah/webdev_tutorial","last_synced_at":"2025-07-28T08:32:37.929Z","repository":{"id":226050324,"uuid":"767518030","full_name":"obaraelijah/webdev_tutorial","owner":"obaraelijah","description":"A tutorial for building Web Services in Rust with Actix-Web, SQLx, and PostgreSQL","archived":false,"fork":false,"pushed_at":"2024-03-20T17:05:04.000Z","size":57,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-10T20:27:44.230Z","etag":null,"topics":["actix-web","api","cargo","postgresql","rust","rust-lang","sqlx","tutorial","webservice"],"latest_commit_sha":null,"homepage":"https://docs.rs/crate/webdev_guide/latest","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/obaraelijah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-05T12:45:21.000Z","updated_at":"2024-07-04T07:46:41.000Z","dependencies_parsed_at":"2024-03-05T16:57:11.045Z","dependency_job_id":"e2a94f36-f23a-410c-b1df-251578617a72","html_url":"https://github.com/obaraelijah/webdev_tutorial","commit_stats":null,"previous_names":["obaraelijah/webdev_tutorial"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obaraelijah%2Fwebdev_tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obaraelijah%2Fwebdev_tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obaraelijah%2Fwebdev_tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obaraelijah%2Fwebdev_tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obaraelijah","download_url":"https://codeload.github.com/obaraelijah/webdev_tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227886373,"owners_count":17834992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actix-web","api","cargo","postgresql","rust","rust-lang","sqlx","tutorial","webservice"],"created_at":"2024-12-03T09:10:59.059Z","updated_at":"2024-12-03T09:10:59.585Z","avatar_url":"https://github.com/obaraelijah.png","language":"Rust","readme":"## Web Service Tutorial in Rust\n\n## Overview\n\nThis project serves as a comprehensive tutorial for building a web service using the Rust programming language. It covers various aspects, from setting up a PostgreSQL database to handling JSON responses.\n\n## Technologies Used\n\n- **Rust**: The core programming language used for this project.\n- **Tokio**: An asynchronous runtime for Rust.\n- **SQLx**: A Rust library for connecting to PostgreSQL databases.\n- **Dotenv**: A Rust crate for handling `.env` files.\n- **Serde**: A Rust crate for serializing and deserializing data structures.\n- **Actix-Web**: A Rust framework for building web services.\n- **Chrono**: A time manipulation library for Rust.\n\n## Documentation\n\nTo generate documentation for this project:\n\n```bash\ncargo doc --open\n```\n\n## Getting Started\n\n### Prerequisites\n\n- Ensure you have Docker Compose installed. If not, you can download it from [Docker Desktop](https://www.docker.com/products/docker-desktop).\n\n### Setup\n\n1. **Environment Variables**: Copy the sample environment file and configure the variables.\n\n    ```bash\n    cp env.example .env\n    ```\n\n2. **Docker Compose**: Start the Docker containers.\n\n    ```bash\n    docker compose up -d\n    ```\n3. **Upload Postman Collection**: Open up Postman locally via the desktop client. Then upload the file entitled `Web Service Tutorial.postman_collection.json`. You should now have    access to the Postman collection.\n4. **Get a Bearer Token**:\n    1. Go to the `create_user` route under the `auth` folder.\n    2. Create a user by hitting the `Send` button. If there's a problem, change both the username and password.\n    3. After you have successfully created a new user, check the headers. Under the `authorization` header, you should see the bearer token. Copy everything after where it says `Bearer`.\n    4. Now click on the `Web Service Tutorial` Postman collection.\n    5. Under the `Authorization` page, you should see a `Type` dropdown.\n    6. Select `Bearer Token`. After you select `Bearer Token`, underneath should apear another dropdown that says `Token`. Paste the copied bearer token here from before. You should now be authorized for four hours, or for however long `JWT_HOURS_ACTIVE` is set to in your .env file.\n    7. If you have any issues hitting the routes, try changing every `localhost:8080` to `http://127.0.0.1:8080`\n\n5. **Test Routes**: Open your browser or use a tool like Postman to hit the following route:\n\n    ```\n    http://127.0.0.1:8080/api/v1/blog\n    ```\n\n### Database GUI (PgAdmin4)\n\n- Access the PgAdmin4 interface at `http://localhost:16543`.\n- Username: `test@test.com`\n- Password: `test`\n\nFor detailed instructions on adding a PostgreSQL server in PgAdmin4, refer to the [PG Admin guide](https://onexlab-io.medium.com/docker-compose-postgres-initdb-ba0021deef76).\n\n### SQL Schema\n\nThe `init.sql` file contains the SQL statements that define the database schema. Feel free to explore it to understand the database structure.\n\n### Authentication\n\nThe `SKIP_AUTH` environment variable controls JWT authentication. Set it to `true` to disable JWT during development.\n\n## Additional Resources\n\n- [Crates.io Package](https://crates.io/crates/webdev_guide)\n- [PG Admin Guide](https://onexlab-io.medium.com/docker-compose-postgres-initdb-ba0021deef76)\n- Medium Post: [Creating a Web Service in Rust with Actix-Web, SQLx, and PostgreSQL](https://medium.com/@elijahobara/building-a-web-service-in-rust-with-actix-web-sqlx-and-postgresql-a70816c07b9c)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobaraelijah%2Fwebdev_tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobaraelijah%2Fwebdev_tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobaraelijah%2Fwebdev_tutorial/lists"}