{"id":23551655,"url":"https://github.com/utkarsh1504/bookie","last_synced_at":"2025-05-15T15:32:05.568Z","repository":{"id":236302449,"uuid":"792338777","full_name":"Utkarsh1504/bookie","owner":"Utkarsh1504","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-26T13:18:29.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T12:18:02.059Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Utkarsh1504.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,"publiccode":null,"codemeta":null}},"created_at":"2024-04-26T13:17:16.000Z","updated_at":"2024-04-26T13:18:32.000Z","dependencies_parsed_at":"2024-04-26T14:44:28.927Z","dependency_job_id":null,"html_url":"https://github.com/Utkarsh1504/bookie","commit_stats":null,"previous_names":["utkarsh1504/bookie"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Utkarsh1504%2Fbookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Utkarsh1504%2Fbookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Utkarsh1504%2Fbookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Utkarsh1504%2Fbookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Utkarsh1504","download_url":"https://codeload.github.com/Utkarsh1504/bookie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254367590,"owners_count":22059535,"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":[],"created_at":"2024-12-26T10:27:26.034Z","updated_at":"2025-05-15T15:32:05.542Z","avatar_url":"https://github.com/Utkarsh1504.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Setup Instructions\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/Utkarsh1504/bookie\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n3. Set up environment variables:\n   - Create a `.env` file in the root directory.\n   - Add the following environment variables:\n     ```\n     PORT=3000\n     MONGO_URL=\u003cyour_mongodb_connection_string\u003e\n     JWT_SECRET=\u003cyour_jwt_secret\u003e\n     ```\n\n4. Start the server:\n\n   ```bash\n   npm run dev\n   ```\n\n## API Endpoints\n\n### User Authentication\n\n- **POST /api/auth/register**\n  - Register a new user.\n  - Request body:\n    ```json\n    {\n      \"name\": \"John Doe\",\n      \"email\": \"john@example.com\",\n      \"password\": \"password\"\n    }\n    ```\n  - Response:\n    ```json\n    {\n      \"message\": \"User registered successfully\",\n      \"user\": {\n        \"_id\": \"5fec4d4b10cc8c33a84d4b25\",\n        \"name\": \"John Doe\",\n        \"email\": \"john@example.com\"\n      }\n    }\n    ```\n\n- **POST /api/auth/login**\n  - Login with existing credentials.\n  - Request body:\n    ```json\n    {\n      \"email\": \"john@example.com\",\n      \"password\": \"password\"\n    }\n    ```\n  - Response:\n    ```json\n    {\n      \"message\": \"Login successful\",\n      \"name\": \"John Doe\",\n      \"email\": \"john@example.com\",\n      \"token\": \"\u003cjwt_token\u003e\"\n    }\n    ```\n\n### Book Management\n\n- **POST /api/books**\n  - Create a new book entry.\n  - Request body:\n    ```json\n    {\n      \"title\": \"Book Title\",\n      \"author\": \"Author Name\",\n      \"price\": 999,\n      \"year\": 2022\n    }\n    ```\n  - Response:\n    ```json\n    {\n      \"message\": \"Book created\",\n      \"book\": {\n        \"_id\": \"5fec4d4b10cc8c33a84d4b26\",\n        \"title\": \"Book Title\",\n        \"author\": \"Author Name\",\n        \"price\": 999,\n        \"year\": 2022\n      }\n    }\n    ```\n\n- **GET /api/books**\n  - Get all books.\n  - Response:\n    ```json\n    {\n      \"message\": \"Books fetched\",\n      \"books\": [\n        {\n          \"_id\": \"5fec4d4b10cc8c33a84d4b26\",\n          \"title\": \"Book Title\",\n          \"author\": \"Author Name\",\n          \"price\": 999,\n          \"year\": 2022\n        },\n        {\n          \"_id\": \"5fec4d4b10cc8c33a84d4b27\",\n          \"title\": \"Another Book\",\n          \"author\": \"Another Author\",\n          \"price\": 999,\n          \"year\": 2020\n        }\n      ]\n    }\n    ```\n\n- **GET /api/books/:id**\n  - Get a book by ID.\n  - Response:\n    ```json\n    {\n      \"message\": \"Book fetched\",\n      \"book\": {\n        \"_id\": \"5fec4d4b10cc8c33a84d4b26\",\n        \"title\": \"Book Title\",\n        \"author\": \"Author Name\",\n        \"price\": 999,\n        \"year\": 2022\n      }\n    }\n    ```\n\n- **PUT /api/books/:id**\n  - Update a book by ID.\n  - Request body (fields to update):\n    ```json\n    {\n      \"title\": \"Updated Title\"\n    }\n    ```\n  - Response:\n    ```json\n    {\n      \"message\": \"Book updated\",\n      \"book\": {\n        \"_id\": \"5fec4d4b10cc8c33a84d4b26\",\n        \"title\": \"Updated Title\",\n        \"author\": \"Author Name\",\n        \"price\": 999,\n        \"year\": 2022\n      }\n    }\n    ```\n\n- **DELETE /api/books/:id**\n  - Delete a book by ID.\n  - Response:\n    ```json\n    {\n      \"message\": \"Book deleted\"\n    }\n    ```\n\n- **GET /api/books/filter/author/:author**\n  - Filter books by author.\n  - Response:\n    ```json\n    {\n      \"message\": \"Books fetched\",\n      \"books\": [\n        {\n          \"_id\": \"5fec4d4b10cc8c33a84d4b26\",\n          \"title\": \"Book Title\",\n          \"author\": \"Author Name\",\n          \"price\": 999,\n          \"year\": 2022\n        }\n      ]\n    }\n    ```\n\n- **GET /api/books/filter/year/:year**\n  - Filter books by publication year.\n  - Response:\n    ```json\n    {\n      \"message\": \"Books fetched\",\n      \"books\": [\n        {\n          \"_id\": \"5fec4d4b10cc8c33a84d4b26\",\n          \"title\": \"Book Title\",\n          \"author\": \"Author Name\",\n          \"price\": 999,\n          \"year\": 2022\n        }\n      ]\n    }\n    ```\n\n## Implementation Details\n\n- **User Authentication**: User registration and login are handled securely using JWT tokens and bcrypt for password hashing.\n- **Input Validation**: Input data for user registration, login, and book operations is validated using Zod schemas to ensure data integrity.\n- **Database**: MongoDB is used as the database to store user and book data.\n- **Security Measures**: Basic security measures such as input validation and JWT token authentication are implemented to protect against common security vulnerabilities.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futkarsh1504%2Fbookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futkarsh1504%2Fbookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futkarsh1504%2Fbookie/lists"}