Giter Site home page Giter Site logo

uoslife-assignment-fe-2's Introduction

과제 목표

  • 주어진 API를 이용하여 Auth 관련 기능을 구현합니다.
  • ky를 이용하여 API를 fetch 해옵니다.
  • CRUD를 구현합니다.

가이드

  • 과제 진행 이전 pnpm install 명령어로 필요한 dependencies를 설치해주세요.
  • 패키지 매니저는 pnpm을 사용합니다.
  • pnpm start 명령어로 프로젝트를 dev환경에서 실행할 수 있습니다.
  • 기본적으로 스타일은 styled-components를 이용하여 구현합니다.
  • 라우팅은 react-router-dom(v6)을 이용하여 구현해주세요. 기본 환경 설정이 되어있습니다.
  • 개인 repository에 fork해서 과제 수행 후 PR을 올려주세요.
  • App.tsx, index.tsx, pages폴더 내부 파일은 변경하지 말아주세요.

API 관련

  • 해당 과제에서 API는 Platzi Fake Store API를 사용합니다.
  • ky를 이용하여 API를 사용해주세요. 사용법은 공식 github를 참고해주세요.
  • 아래와 같이 instance가 생성되어 있습니다. 생성된 instance를 사용하여 API를 이용해주세요.
// src/api/index.ts
import ky from 'ky';

export const API = ky.create({
  timeout: 10 * 1000,
  prefixUrl: 'https://api.escuelajs.co/api/v1',
});

export default API;
  • 새로 생성된 Ky instance 사용법은 url을 통해 알 수 있습니다.

구현 요구 사항

Auth

요구사항 1.로그인 기능을 구현해주세요

[POST] https://api.escuelajs.co/api/v1/auth/login
# Body
{
  "email": "[email protected]",
  "password": "changeme"
}
  • API docs
  • 로그인 폼을 만들고 상기 API를 이용하여 예시 email, password를 입력 후 제출했을 때 Main page로 redirect하도록 구현해주세요.
  • access_token과 refresh_token은 localstorage에 저장해주세요.
  • 로그인 폼 디자인은 자유롭게 구현해도 좋습니다.

요구사항 2.로그인 유지 기능을 구현해주세요

[GET] https://api.escuelajs.co/api/v1/auth/profile
# Headers
{
  "Authorization": "Bearer {your access token}"
}
  • API docs
  • 브라우저 새로고침시에도 로그인이 유지되어야 합니다.
  • localstorage에 저장된 access_token을 이용하여 해당 API를 사용해주세요.
  • 해당 API의 response code가 401이라면 로그아웃되고 login페이지로 redirect되어야 합니다.
  • 로그인 상태에서 login페이지('/login')에 접근시 알림 문구와 함께 메인페이지로 redirect되어야 합니다.
  • 마찬가지로 로그아웃 상태에서 main페이지('/')에 접근시 알림 문구와 함께 login페이지로 redirect되어야 합니다.

요구사항 3.로그아웃 기능을 구현해주세요

  • Main page의 로그아웃 버튼을 클릭하면 로그아웃되며 login페이지로 redirect되어야 합니다.
  • 로그아웃시 localstorage의 token정보를 삭제해주세요.

추가 요구사항 1.access token 만료시 refresh token을 받아와 로그인 상태를 유지해주세요

[POST] https://api.escuelajs.co/api/v1/auth/refresh-token
# Body
{
  "refreshToken": "{your refresh token}"
}
  • API docs
  • access token이 만료되었다면 응답 코드가 401이므로 기존 구현에서는 로그아웃되어야 하지만, 저장된 refresh token으로 새로운 access token을 발급받아 로그인을 유지시킬 수 있습니다.
  • src/api/index.ts 파일을 수정하여 구현해주세요.
  • 참고 문서: https://github.com/sindresorhus/ky#hooksafterresponse

Category

요구사항 1.category API를 이용하여 category를 불러와주세요

요구사항 2.category를 생성합니다

요구사항 3.category를 삭제합니다

참고 문서 링크

uoslife-assignment-fe-2's People

Contributors

ratafa avatar eunbae0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.