{"id":17359702,"url":"https://github.com/robbypambudi/bookshelf-api-backend","last_synced_at":"2025-03-27T15:33:09.861Z","repository":{"id":134655602,"uuid":"447164810","full_name":"robbypambudi/bookshelf-api-backend","owner":"robbypambudi","description":"Project membuat bookshelf API  sebagai syarat untuk memperoleh sertifikat dari Dicoding : Belajar membuar aplikasi backend untuk pemula","archived":false,"fork":false,"pushed_at":"2022-01-12T10:20:17.000Z","size":2906,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T19:23:00.048Z","etag":null,"topics":["backend-api","hapi","nanoid","rest-api"],"latest_commit_sha":null,"homepage":"","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/robbypambudi.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":"2022-01-12T10:01:44.000Z","updated_at":"2022-01-12T14:07:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"6f192701-fb9b-436c-b528-7695cabc76d1","html_url":"https://github.com/robbypambudi/bookshelf-api-backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robbypambudi%2Fbookshelf-api-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robbypambudi%2Fbookshelf-api-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robbypambudi%2Fbookshelf-api-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robbypambudi%2Fbookshelf-api-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robbypambudi","download_url":"https://codeload.github.com/robbypambudi/bookshelf-api-backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245872196,"owners_count":20686335,"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":["backend-api","hapi","nanoid","rest-api"],"created_at":"2024-10-15T19:10:56.655Z","updated_at":"2025-03-27T15:33:09.825Z","avatar_url":"https://github.com/robbypambudi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Submission Bookshelf API\n\nDibuat untuk menyelesaikan kelas **Belajar Membuat Aplikasi Back-End untuk pemula - Dicoding** dengan membuat proyek **Bookshelf API** sesuai dengan kriteria dibawah ini :\n\n## Kriteria Bookshelf API\n\nTerdapat 5 kriteria yang diberikan oleh dicoding academy yaitu :\n\n### Kriteria 1 : API dapat menyimpan buku\n\nAPI dibuat harus dapat menyimpan buku melalui route :\n\n-   Method : **POST**\n-   URL : ```/books```\n-   Body Request :\n    ```\n    { \n     \"name\": string,\n     \"year\": number,\n     \"author\": string, \n     \"summary\": string, \n     \"publisher\": string, \n     \"pageCount\": number, \n     \"readPage\": number, \n     \"reading\": boolean \n     }\n     ```\n\n    Server harus merespon gagal bila :\n-   Client tidak melamprikan properti **name** pada *request body* dan akan merespons dengan :\n    \n    ~ Status code : 400 \u003cbr\u003e\n    ~ Response Body : \n    ```\n    {\n        \"status\": \"fail\",\n        \"message\": \"Gagal menambahkan buku. Mohon isi nama buku\"\n    }\n    ```\n- Apabila client melampirkan nilai properti **readPage** \u003e **pageCount** maka server akan meresponse dengan :\n  \n    ~ Status Code : 400 \u003cbr\u003e\n    ~ Response Body : \n    ```\n    {\n        \"status\": \"fail\",\n        \"message\": \"Gagal menambahkan buku. Mohon isi nama buku\"\n    }\n    ```\n\n- Apabuka gagal memasukan buku karena alasan umum (*Generic Error*) maka server akan merespons dengan :\n  \n  ~ Status Code : 500 \u003cbr\u003e\n  ~ Response Body :\n  ```\n      {\n        \"status\": \"error\",\n        \"message\": \"Buku gagal ditambahkan\"\n    }\n  ```\n- Apabila buku **Berhasil Dimasukan**, maka server mengembalikan response dengan : \n  \n    ~ Status Code : 201 \u003cbr\u003e\n    ~ Response Body :\n    ```\n        {\n        \"status\": \"success\",\n        \"message\": \"Buku berhasil ditambahkan\",\n        \"data\": {\n            \"bookId\": \"XXXXXX\"\n        }\n    }\n    ```\n\n### Kriteria 2 : API dapat menampilkan seluru Buku\nAPI yang dibuat harus dapt menampilkan seluru buku yang disimpan melalui route :\n\n- Method    : **GET**\n- URL       : ```/books```\n  \nServer harus mengembalikan response dengan :\n- Status Code : 200\n- Response Body :\n  ```\n      {\n        \"status\": \"success\",\n        \"data\": {\n            \"books\": [\n                {\n                    \"id\": \"XXXX\",\n                    \"name\": \"Buku \",\n                    \"publisher\": \"Dicoding Indonesia\"\n                },\n                {\n                    \"id\": \"XXXX\",\n                    \"name\": \"Buku B\",\n                    \"publisher\": \"Dicoding Indonesia\"\n                },\n                {\n                    \"id\": \"XXXX\",\n                    \"name\": \"Buku C\",\n                    \"publisher\": \"Dicoding Indonesia\"\n                }\n            ]\n        }\n    }\n  ```\n  Jika buku masi kosong maka server akan merespons dengan :\n  ```\n      {\n        \"status\": \"success\",\n        \"data\": {\n            \"books\": []\n        }\n    }\n  ```\n\n### Kriteria 3 : API dapat menampilkan detail buku\nAPI yang dibuat harus dapat menampilkan detail buku yang disimpan di dalam server dengan :\n- Method : **GET**\n- URL : ```/books/{bookId}```\n  \nBila buku dengan id yang dilampirkan oleh client tidak ditemukan, maka server harus mengembalikan respons dengan:\n- Status Code : 404\n- Response Body : \n  ```\n    {\n        \"status\": \"fail\",\n        \"message\": \"Buku tidak ditemukan\"\n    }\n  ```\n\nBila buku dengan id yang dilampirkan ditemukan, maka server harus mengembalikan respons dengan:\n- Status Code : 200\n- Response Body :\n    ```\n    {\n        \"status\": \"success\",\n        \"data\": {\n            \"book\": {\n                \"id\": \"aWZBUW3JN_VBE-9I\",\n                \"name\": \"Buku A Revisi\",\n                \"year\": 2011,\n                \"author\": \"Jane Doe\",\n                \"summary\": \"Lorem Dolor sit Amet\",\n                \"publisher\": \"Dicoding\",\n                \"pageCount\": 200,\n                \"readPage\": 26,\n                \"finished\": false,\n                \"reading\": false,\n                \"insertedAt\": \"2021-03-05T06:14:28.930Z\",\n                \"updatedAt\": \"2021-03-05T06:14:30.718Z\"\n            }\n        }\n    }\n    ```\n### Kriteria 4 : API dapat mengubah data buku\nAPI harus dapat mengubah data buku berdasarkan **id** melalui route :\n- Method : PUT\n- URL : ```/books/{bookId}```\n- Body Request :\n    ```\n    {\n        \"name\": string,\n        \"year\": number,\n        \"author\": string,\n        \"summary\": string,\n        \"publisher\": string,\n        \"pageCount\": number,\n        \"readPage\": number,\n        \"reading\": boolean\n    }\n    ```\nServer harus merespons gagal bila :\n- Client tidak melampirkan properti **name** pada *request body*. Bila hal ini terjadi maka *server* akan merespons dengan :\n  - Status Code : 400\n  - Response Body : \n    ```\n    {\n        \"status\": \"fail\",\n        \"message\": \"Gagal memperbarui buku. Mohon isi nama buku\"\n    }\n    ```\n- Client melampirkan nilai properti **readPage** \u003e **pageCount**. Bila hal ini terjadi maka *server* akan meresponse dengan :\n  - Status Code : 400\n  - Response Body : \n    ```\n    {\n        \"status\": \"fail\",\n        \"message\": \"Gagal memperbarui buku. readPage tidak boleh lebih besar dari pageCount\"\n    }\n    ```\n- **Id** yang dilampirkan oleh client tidak ditemukkan oleh *server*. Bila hal ini terjadi, maka *server* akan merespons dengan:\n  - Status Code : 404\n  - Response Body : \n    ```\n    {\n        \"status\": \"fail\",\n        \"message\": \"Gagal memperbarui buku. Id tidak ditemukan\"\n    }\n    ```\n- Bila buku **berhasil diperbarui**, server harus mengembalikan respons dengan:\n  - Status Code :200\n  - Response Body : \n    ```\n    {\n        \"status\": \"success\",\n        \"message\": \"Buku berhasil diperbarui\"\n    }\n    ```\n\n### Kriteria 5 : API dapat menghapus buku\n- Method : DELETE\n- URL : ```/books/{bookId}```\n  \nBila **id** yang dilampirkan tidak dimiliki oleh buku manapun, maka server harus mengembalikan respons berikut:\n- Status Code : 404\n- Response Body : \n    ```\n    {\n        \"status\": \"fail\",\n        \"message\": \"Buku gagal dihapus. Id tidak ditemukan\"\n    }\n    ```\nBila **id** dimiliki oleh salah satu buku, maka buku tersebut harus dihapus dan server mengembalikan respons berikut:\n- Status Code : 200\n- Response Body : \n    ```\n    {\n        \"status\": \"success\",\n        \"message\": \"Buku berhasil dihapus\"\n    }\n    ```\n---\n\n## Pengujian API\n\nUntuk memastikan API berjalan sesuai kriteria maka dilakukan pengujian mengunakan software *postman* dengan configurasi file sebagai berikut :\n\n[Berkas Pengujian](https://github.com/dicodingacademy/a261-backend-pemula-labs/raw/099-shared-files/BookshelfAPITestCollectionAndEnvironment.zip) \n\n![Preview](./img/image-1.png)\n\nJika sudah siap maka jalankan pengujian terhadap API yang sudah dibuat : \n\n\nhttps://user-images.githubusercontent.com/34505233/149121703-3bd13029-a1e8-4c38-9076-20ba37e6ec56.mov\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobbypambudi%2Fbookshelf-api-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobbypambudi%2Fbookshelf-api-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobbypambudi%2Fbookshelf-api-backend/lists"}