Skip to content

Commit

Permalink
add asssignment 06
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanh Pham committed Oct 3, 2023
1 parent 29f395a commit 49b61c3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Welcome to the Frontend Training 2023 repository! This is where you'll find exer
| 3 | [Tooling: Webpack, Babel, TypeScript, ESLint & Prettier](./assignment-3/) | 01/10/2023 |
| 4 | [NextJS & TailwindCSS](./assignment-4/) | 06/10/2023 |
| 5 | [Form handling](./assignment-5/) | 08/10/2023 |
| 6 | Authentication & API Integration | |
| 6 | [Authentication & API Integration](./assignment-6/) | 13/10/2023 |
| 7 | Type-safe client server | |
| 8 | Modern workflow & Deployment | |

Expand Down
Binary file added assets/bookstore-api-account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions assignment-6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Authentication & API Integration

With your foundational work from Assignments 04 & 05, it's time to turn your Next.js application into a dynamic powerhouse by integrating with a backend API. The goal for this assignment is to introduce the integration of backend services, understand protected routes, and API caching mechanism.

Refer to the API documentation at: [**Bookstore API Docs**](https://develop-api.bookstore.dwarvesf.com/swagger/index.html).

## **Requirements**

- Begin by incorporating the functionalities already built in the Next.js application from [Assignment 05](../assignment-5/).
- Seamlessly integrate the APIs into the UI.
- Protect all routes, exempting the `/login` route. Unauthorized access to protected routes should redirect the user back to the login page.
- Incorporate a "Log out" button prominently within the application header. This button should effectively log out the user and redirect to the login page.
- Implement caching for the responses obtained from GET APIs. The intention is to provide an almost instantaneous loading experience for the end user.

**Create account to authorize APIs**

- Head to API swagger documentation at: [**Bookstore API Docs**.](https://develop-api.bookstore.dwarvesf.com/swagger/index.html#/Auth/signup)
- Expand the accordion row [POST] `auth/signup`.
- Next, click on `Try it out` button, and input the account information into the body data.
- After that, click on the `Execute` button to make the API call.
- If you receive the status below, it means your account has been successfully created.

![success-created-account](../assets/bookstore-api/../bookstore-api-account.png)

### **Deliverables**

- Ensure that the form, authentication mechanisms, data caching, and protected routes correctly represent their intended states.
- Assure that the code is thoroughly formatted and aligns with comprehensive coding conventions.
- Confirm the project's deployability and, as proof, provide a working demo link for review and assessment.
- **Bonus:** Revoke access if an API responds 401 error code.
- **Bonus:** Elevate your application's security and performance by storing user credentials securely using cookies and implementing Server Side Rendering (SSR) for all the pages.

### **What Are We Looking For?**

- Proficiently leveraging data fetching, SWR, and navigating protected routes with authentication.
- Completing the implementation of all the features outlined in the requirements.
- Demonstrating clear improvement and the successful integration of feedback received from previous assignments.

## **Submission**

- Ensure all assignment code is neatly contained within the **`/assignment-6`** directory. Transfer any necessary application code from your previous assignments into this directory.
- The last date to ensure your submission is **13/10/2023**.
- Upon finalizing your work and ensuring that your demo is deployable, initiate a Github issue in your forked repository titled "**Submission for Assignment 6**." Remember to include the demo link within the issue's description for easy accessibility.

0 comments on commit 49b61c3

Please sign in to comment.