{"id":31673149,"url":"https://github.com/dscmatter/bookapis","last_synced_at":"2025-10-08T03:35:41.575Z","repository":{"id":307145784,"uuid":"1025543497","full_name":"DSCmatter/BookAPIs","owner":"DSCmatter","description":"A backend API for a Book Review Platform built with Node.js, Express, TypeScript, and PostgreSQL. It provides secure user authentication, book management, and review features with JWT-based access control, pagination, and average rating calculations.","archived":false,"fork":false,"pushed_at":"2025-09-04T20:44:20.000Z","size":89,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-04T22:26:44.571Z","etag":null,"topics":["api-rest","express","jwt","nodejs","postgresql-database","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DSCmatter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-24T12:16:22.000Z","updated_at":"2025-09-04T20:49:14.000Z","dependencies_parsed_at":"2025-07-29T19:19:43.934Z","dependency_job_id":"085ed9ab-ebe8-4339-9d9e-dce3d251697d","html_url":"https://github.com/DSCmatter/BookAPIs","commit_stats":null,"previous_names":["dscmatter/pagecritic"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DSCmatter/BookAPIs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSCmatter%2FBookAPIs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSCmatter%2FBookAPIs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSCmatter%2FBookAPIs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSCmatter%2FBookAPIs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DSCmatter","download_url":"https://codeload.github.com/DSCmatter/BookAPIs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSCmatter%2FBookAPIs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278886147,"owners_count":26062972,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api-rest","express","jwt","nodejs","postgresql-database","typescript"],"created_at":"2025-10-08T03:35:40.746Z","updated_at":"2025-10-08T03:35:41.570Z","avatar_url":"https://github.com/DSCmatter.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PageCritic\n\nIs a set of backend API for a Book Review Platform, built with **Node.js**, **Express**, **TypeScript**, and **PostgreSQL**. It provides a robust set of RESTful endpoints for user authentication, book management, and review functionalities.\n\n---\n\n## Features\n\n### User Authentication\n\n* User registration (Signup).\n* User login, returning a JSON Web Token (JWT) for authentication.\n* Protected routes accessible only by authenticated users.\n* Retrieve authenticated user's profile.\n* Delete a user's own account.\n\n### Book Management\n\n* Add new books (title, author, genre) - authenticated access only.\n* Retrieve a paginated list of all books.\n* Filter books by genre and/or author.\n* View details of a single book, including its average rating and associated reviews.\n* Delete books - authenticated access only.\n\n### Review Management\n\n* Add reviews and ratings (1-5 stars) to books - authenticated access only.\n* View all reviews for a specific book (integrated into book detail endpoint).\n* Delete reviews - authenticated access only, only the original reviewer can delete their own review.\n* Automatically calculates and displays the average rating for each book.\n\n---\n\n## Technologies Used\n\n* **Runtime:** Node.js\n* **Language:** TypeScript\n* **Web Framework:** Express.js\n* **Database:** PostgreSQL\n* **Database Client:** `pg` (Node.js PostgreSQL client)\n* **Authentication:** JWT with `jsonwebtoken` and `bcryptjs` for password hashing.\n* **Environment Variables:** dotenv\n\n---\n\n## Getting Started\n\nFollow these steps to set up and run the backend locally.\n\n### Prerequisites\n\nEnsure you have the following installed on your system:\n\n* Node.js (LTS version recommended)\n* npm (comes with Node.js) or pnpm\n* PostgreSQL (version 14 or higher recommended)\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/DSCmatter/PageCritic\ncd PageCritic\n```\n\n### 2. Backend Setup\n\nNavigate into the backend directory and install dependencies:\n\n```bash\ncd backend\nnpm install # or pnpm install\n```\n\n### 3. Environment Variables\n\nCreate a `.env` file in the `backend/` directory and add the following configuration:\n\n```env\n# PostgreSQL Database Configuration\nDB_USER=book_app_user\nDB_PASSWORD=some-passwd\nDB_HOST=localhost\nDB_PORT=5432\nDB_DATABASE=book_review_db\n\n# JWT Configuration\nJWT_SECRET=your_super_secret_jwt_key_here_make_it_long_and_random\nJWT_EXPIRES_IN=1h\n\n# Server Configuration\nPORT=5000\n```\n\n### 4. PostgreSQL Database Setup\n\n**Create the database and user:**\n\nFeel free to replace `some-passwd` with your own.\n\n```sql\nCREATE DATABASE book_review_db;\nCREATE USER book_app_user WITH PASSWORD 'some-passwd';\nGRANT ALL PRIVILEGES ON DATABASE book_review_db TO book_app_user;\n```\n\n**Initialize the schema:**\nCreate a file `backend/sql/init.sql` and add the schema provided in the documentation. Then run:\n\n```bash\npsql -U book_app_user -d book_review_db -h localhost -p 5432 -f sql/init.sql\n```\n\nTo know more about the different commands used to navigate, inspect and query this database, please check out [the PostgreSQL Command Line (psql) Navigation Guide.](psqlCMDs.md)\n\n### 5. Run the Backend Server\n\n```bash\nnpm run dev\n```\n\nServer will start on [http://localhost:5000](http://localhost:5000).\n\n---\n\n## API Endpoints (Backend)\n\nAll endpoints are prefixed with `/api`.\n\n### Authentication\n\n* **POST /api/auth/signup** – Register a new user.\n* **POST /api/auth/login** – Authenticate user and get JWT.\n* **GET /api/auth/me** – Get current authenticated user's profile (Protected).\n* **DELETE /api/auth/me** – Delete the current authenticated user's account (Protected).\n\n### Books\n\n* **POST /api/books** – Add a new book (Protected).\n* **GET /api/books** – Get all books with filters and pagination.\n* **GET /api/books/\\:id** – Get details of a single book.\n* **DELETE /api/books/\\:id** – Delete a book by ID (Protected).\n\n### Reviews\n\n* **POST /api/books/\\:id/reviews** – Add a review to a specific book (Protected).\n* **DELETE /api/reviews/\\:id** – Delete a review (Protected).\n\nMore information about these endpoints are described in [apiResponses.md](apiResponses.md)\n\n---\n\n## Database Schema\n\n### `users`\n\n* `id` (UUID, PK)\n* `username` (VARCHAR, UNIQUE)\n* `email` (VARCHAR, UNIQUE)\n* `password` (VARCHAR, HASHED)\n* `created_at` (TIMESTAMP)\n\n### `books`\n\n* `id` (UUID, PK)\n* `title` (VARCHAR)\n* `author` (VARCHAR)\n* `genre` (VARCHAR)\n* `created_at` (TIMESTAMP)\n\n### `reviews`\n\n* `id` (UUID, PK)\n* `book_id` (UUID, FK to books.id, ON DELETE CASCADE)\n* `reviewer_id` (UUID, FK to users.id, ON DELETE CASCADE)\n* `review_text` (TEXT)\n* `rating` (INTEGER, 1-5)\n* `created_at` (TIMESTAMP)\n\n---\n\n## Known Limitations\n\n* No extensive input validation.\n* No user roles (e.g., admin).\n* Basic error handling.\n* No rate limiting or advanced security.\n\n---\n\n## Future Enhancements\n\n* Robust input validation.\n* User roles (Admin, Reviewer).\n* Password reset functionality.\n* Image uploads for book covers.\n* Advanced sorting and search.\n* Logging integration.\n* Unit and integration tests.\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdscmatter%2Fbookapis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdscmatter%2Fbookapis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdscmatter%2Fbookapis/lists"}