{"id":19351150,"url":"https://github.com/rokibulhasan7/book-api","last_synced_at":"2026-05-19T10:32:20.189Z","repository":{"id":94304075,"uuid":"590319316","full_name":"RokibulHasan7/book-api","owner":"RokibulHasan7","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-09T08:37:58.000Z","size":11733,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T09:34:34.494Z","etag":null,"topics":["docker","dockerfile","go-api","go-chi","go-jwt","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/RokibulHasan7.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":"2023-01-18T06:05:50.000Z","updated_at":"2023-01-25T07:07:08.000Z","dependencies_parsed_at":"2023-04-25T20:40:17.327Z","dependency_job_id":null,"html_url":"https://github.com/RokibulHasan7/book-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RokibulHasan7/book-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RokibulHasan7%2Fbook-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RokibulHasan7%2Fbook-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RokibulHasan7%2Fbook-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RokibulHasan7%2Fbook-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RokibulHasan7","download_url":"https://codeload.github.com/RokibulHasan7/book-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RokibulHasan7%2Fbook-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268378808,"owners_count":24240896,"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-08-02T02:00:12.353Z","response_time":74,"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":["docker","dockerfile","go-api","go-chi","go-jwt","golang"],"created_at":"2024-11-10T04:35:20.355Z","updated_at":"2026-05-19T10:32:20.158Z","avatar_url":"https://github.com/RokibulHasan7.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REST API Server in Golang\n\n- This is the API Server for a **Book Store**. It allows users to perform Login, Logout into the site and **CRUD** (create, read, update, and delete) operations on the store's inventory of books.\n\n## To Start API Server\n```\n$ git clone https://github.com/RokibulHasan7/bookApi-server.git\n```\n```\n$ cd book-api\n```\n\n## Command to run unit test for API endpoints\n```\n$ cd api\n```\n```\n$ go test\n```\n\n## Data Model\n\n- User Model\n``````\ntype User struct {\n\tUserName string `json:\"username\"`\n\tPassword string `json:\"password\"`\n}\n``````\n- Book Model\n``````\ntype Book struct {\n\tId          string   `json:\"id\"`\n\tName        string   `json:\"name\"`\n\tISBN        string   `json:\"isbn\"`\n\tPublishDate string   `json:\"publishDate\"`\n\tAuthorList  []Author `json:\"author\"`\n}\n``````\n- Author Model\n``````\ntype Author struct {\n\tFirstName string `json:\"firstName\"`\n\tLastName  string `json:\"lastName\"`\n\tEmail     string `json:\"email\"`\n}\n``````\n## Available API Endpoints\n\n|  Method | API Endpoint       | Authentication Type              | Description                                                           |\n|---|--------------------|----------------------------------|-----------------------------------------------------------------------|\n|POST| /api/v1/login      | Basic                            | Return jwt token in response for successful authentication            |\n|POST| /api/v1/logout     | Basic or Bearer token            | Clean token                                                           |\n|GET| /api/v1/books      | Basic or Bearer token or No Auth | Return a list of all Books in response                                | \n|GET| /api/v1/books/{id} | Basic or Bearer token or No Auth | Return the data of given Book id in response                          | \n|GET| /api/v1/books/isbn/{isbn} | Basic or Bearer token or No Auth | Return the data of given Book ISBN in response                        |\n|POST| /api/v1/books      | Basic or Bearer token            | Add a Book in the database and return the added Book data in response | \n|PUT| /api/v1/books/{id} | Basic Bearer token               | Update the Book and return the updated Book info in response          | \n|DELETE| /api/v1/books/{id} | Basic or Bearer token            | Delete the Book and return the deleted user data in response          | \n\n\n## Sample Curl commands without authentication\n\nRun API server without authentication\n\n```shell\n$ go run main.go\n``` \nOn the other CLI run these commands:-\n\nGet all Books information\n\n```shell\n$ curl -X GET http://localhost:3333/api/v1/books\n``` \n\nGet Book information with id 1\n\n```shell\n$ curl -X GET http://localhost:3333/api/v1/books/1\n```\n\nGet Book information with ISBN 14-14-14\n```shell\n$ curl -X GET http://localhost:3333/api/v1/books/isbn/14-14-14\n```\n\n## Sample Curl commands with Basic authentication\n\nRun API server with authentication\n\n```shell\n$ go run main.go\n``` \nOn the other CLI run these commands:-\n\nGet all Books information\n\n```shell\n$ curl -X GET --user rakib:1234 http://localhost:3333/api/v1/books\n``` \n\nGet Book information with id 1\n\n```shell\n$ curl -X GET --user rakib:1234 http://localhost:3333/api/v1/books/1\n```\n\nGet Book information with ISBN 14-14-14\n```shell\n$ curl -X GET --user rakib:1234 http://localhost:3333/api/v1/books/isbn/14-14-14\n```\n\nCreate a New Book\n\n```shell\n$ curl -X POST  --user rakib:1234 -d '{\"id\":\"6\",\"name\":\"testfirst\",\"isbn\":\"testIsbn\",\"publishDate\":\"12/12/12\",\"author\":[{\"firstName\":\"testname\",\"lastName\":\"testlast\",\"email\":\"test@gmail.com\"}]}' http://localhost:3333/api/v1/books\n``` \n\nUpdate user data with given id\n\n```shell\n$ curl -X PUT  --user rakib:1234 -d '{\"name\":\"testfirst\",\"publishDate\":\"12/12/12\"}' http://localhost:3333/api/v1/books/1\n``` \n\nDelete user with given id\n\n```shell\n$ curl -X DELETE --user rakib:1234 http://localhost:3333/api/v1/books/1\n``` \n\n## Sample Curl commands with Bearer token(JWT token) authentication\n\nRun API server with authentication\n\n```shell\n$ go run main.go\n``` \nOn the other CLI run these commands:-\n\nGet jwt token via login with basic authentication\n\n```shell\n$ curl -X POST --user rakib:1234  http://localhost:3333/login\n``` \n\nGet all Books information\n\n```shell\n$ curl -X GET -H \"Authorization: Bearer \u003cjwt_token\u003e\"  http://localhost:3333/api/v1/books\n``` \n\nGet Book information with id 1\n\n```shell\n$ curl -X GET -H \"Authorization: Bearer \u003cjwt_token\u003e\" http://localhost:3333/api/v1/books/1\n``` \n\nCreate a New Book\n\n```shell\n$ curl -X POST -H \"Authorization: Bearer \u003cjwt_token\u003e\" -d '{\"id\":\"6\",\"name\":\"testfirst\",\"isbn\":\"testIsbn\",\"publishDate\":\"12/12/12\",\"author\":[{\"firstName\":\"testname\",\"lastName\":\"testlast\",\"email\":\"test@gmail.com\"}]}' http://localhost:3333/api/v1/books\n``` \n\nUpdate Book data with given id\n\n```shell\n$ curl -X PUT -H \"Authorization: Bearer \u003cjwt_token\u003e\" -d '{\"name\":\"test\",\"publishDate\":\"test\"}' http://localhost:3333/api/v1/books/1 \n``` \n\nDelete Book with given id\n\n```shell\n$ curl -X DELETE -H \"Authorization: Bearer \u003cjwt_token\u003e\" http://localhost:3333/api/v1/books/1\n``` ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frokibulhasan7%2Fbook-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frokibulhasan7%2Fbook-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frokibulhasan7%2Fbook-api/lists"}