Giter Club home page Giter Club logo

simple-user-api's Introduction

user API 1.0

[κ°œλ°œν™˜κ²½]

  • Docker Container (mysql + nginx + php)
  • Codeigniter 4
  • Mac OS

πŸ‘‰ ν…Œμ΄λΈ” 생성 쿼리문

Getting Started

docker ν™˜κ²½ μ…‹νŒ…

  1. ν”„λ‘œμ νŠΈ root 폴더에 codeignaiter.zip μ••μΆ• ν’€κΈ°
  2. ν”„λ‘œμ νŠΈ root 폴더에 phpdocker.zip μ••μΆœ ν’€κΈ°
$ cd /phpdocker/php-fpm/php-ini-override.ini
$ nano php-ini-override.ini
  1. ini νŒŒμΌμ— μ„€μ • μΆ”κ°€ν•˜κΈ°
date.timezone = Asia/Seoul
short_open_tag = On
  1. ν”„λ‘œμ νŠΈ root ν΄λ”μ—μ„œ docker compose μ‹€ν–‰ν•˜μ—¬ μ»¨ν…Œμ΄λ„ˆ 생성
$ docker-compose up -d

user/get

μ•„μ΄λ””λ‘œ λ‹¨μΌνšŒμ› 상세 정보 쑰회

  • URL
    http://localhost:18080/user/getbyid

  • Method:
    GET | POST

  • Params
    Required:
    id=[Integer]

    Optional:

  • Success Response:

    {
        "status": "success",
        "user": {
            "id": "3",
            "name": "μ•ˆμžμš”",
            "nickname": "mihee",
            "password": "$2y$10$TM8oYiQHoXF3Zbrab346ZO3pKkhzmBWLqd6NBmBILOUzxHvbCBMT.",
            "tel": "01022341234",
            "email": "[email protected]",
            "gender": "F",
            "creationtime": "2020-04-23 21:26:03"
        }
    }
  • Error Response:

    {
        "status": "error",
        "messages": "Undefined index: id"
    }

    OR

    {
       "status": "error",
       "messages": "Not Found"
    }

user/fetch

μ—¬λŸ¬ νšŒμ› λͺ©λ‘ 정보 쑰회

  • Url
    http://localhost:18080/user/fetch

  • Method
    GET | POST

  • Params
    Required:

    Optional:
    name=[Stinrg]
    email=[String]
    limit=[Integer] //κΈ°λ³Έκ°’ 1000
    offset=[Integer] //κΈ°λ³Έκ°’ 0

  • Success Response:

    {
        "status": "success",
        "users": [
            {
                "id": "1",
                "name": "mihee",
                "nickname": "mihee",
                "password": "$2y$10$Wur5AddUJHWj8eghSz2dyu8LXHudFicNdrUC50B/4xwU573jO/hoK",
                "tel": "01022341234",
                "email": "[email protected]",
                "gender": "M",
                "creationtime": "2020-04-23 21:09:23"
            },
            {
                "id": "2",
                "name": "μ•ˆμžμš”",
                "nickname": "mihee",
                "password": "$2y$10$yKkR9658dnK6iFvjeybX6eNlG2OIaCe414/Lr1JlGOdHCtaozn98G",
                "tel": "01022341234",
                "email": "[email protected]",
                "gender": "F",
                "creationtime": "2020-04-23 21:11:33"
            }
        ]
    }
        ```
  • Error Response:

    {
        "status": "error",
        "messages": "Not Found"
    }

user/create

μ‹ κ·œ νšŒμ›μ •λ³΄ μƒμ„±ν•˜κΈ°

  • Url
    http://localhost:18080/user/create

  • Method:
    GET| POST

  • Params
    Required:
    name=[String] //μ΅œλŒ€ 길이 20자, ν•œκΈ€, 영문 λŒ€μ†Œλ¬Έμž
    nickname=[String]//μ΅œλŒ€ 길이 30자, 영문 μ†Œλ¬Έμž
    password=[String] //μ΅œμ†Œ 길이 10자, 영문 λŒ€λ¬Έμž, 영문 μ†Œλ¬Έμž, 특수문자, 숫자 각 1개 이상씩 포함
    email=[String] //μ΅œλŒ€ 길이 100자
    tel=[Integer] //μ΅œλŒ€ 길이 20자

    Optional:
    gender=[String] //μ΅œλŒ€ 길이 1자, β€˜F’ or β€˜M’ κ°’μ™Έμ—λŠ” λΉˆκ°’μ²˜λ¦¬

  • Success Response:

    {
        "status": "success",
        "messages": "create new user. id: 6"
    }
  • Error Response:

    {
        "status": "error",
        "messages": "invalid request"
    }

    OR

    {
        "status": "error",
        "messages": {
            "name": "The name field is not in the correct format.",
            "nickname": "The nickname field is not in the correct format.",
            "password": "The password field is not in the correct format.",
            "email": "The email field must contain a unique value.",
            "tel": "The tel field must only contain digits and must be greater than zero.",
            "gender": "The gender field is not in the correct format."
        }
    }  

user/login

νšŒμ› 둜그인(인증)

  • Url
    http://localhost:18080/user/lgoin

  • Method:
    GET| POST

  • Params
    Required:
    email=[String]
    password=[String]

    Optional:

  • Success Response:

    {
        "status": "success",
        "accessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtaWhlZSIsInN1YiI6IjUiLCJpYXQiOjE1ODc3MTUzMTEsImV4cCI6MTU4NzcxODkxMX0.8lvtDRrHpazSGH6UWdM0NeVHz9xSrwNZnqeYsItLeJU",
        "tokenType": "Bearer",
        "expireTime": 1587718911
    }
  • Error Response:

    {
        "status": "error",
        "messages": "Not Found"
    }

user/logout

νšŒμ› λ‘œκ·Έμ•„μ›ƒ

  • Url
    http://localhost:18080/user/logout

  • Method:
    GET|POST

  • Header Authorization=μ ‘κ·Ό 토큰(access token)을 μ „λ‹¬ν•˜λŠ” 헀더

    μš”μ²­ 헀더 예

    Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtaWhlZSIsInN1YiI6IjMiLCJpYXQiOjE1ODc2NzcxNjgsImV4cCI6MTU4NzY4MDc2OH0.v1t5tkYVdQ2XMN2fpM-xCSyzcr0pw0r0CSGJ4jIdo0M
    
  • Success Response:

    {
        "status": "success",
        "message": "logout"
    }
  • Error Response:

    {
        "status": "error",
        "messages": "Authentication failed"
    }

user/token/refresh

accesstoken κ°±μ‹ 

  • Url
    http://localhost:18080/user/token/refresh

  • Method:
    GET|POST

  • Header Authorization=μ ‘κ·Ό 토큰(access token)을 μ „λ‹¬ν•˜λŠ” 헀더

    μš”μ²­ 헀더 예

    Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtaWhlZSIsInN1YiI6IjMiLCJpYXQiOjE1ODc2NzcxNjgsImV4cCI6MTU4NzY4MDc2OH0.v1t5tkYVdQ2XMN2fpM-xCSyzcr0pw0r0CSGJ4jIdo0M
  • Success Response:

    {
        "status": "success",
        "accessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtaWhlZSIsInN1YiI6IjUiLCJpYXQiOjE1ODc3MTA2ODksImV4cCI6MTU4NzcxNDI4OX0.OJ6mn-kbWDDY4NAQMWAzXvC-Fut3gCOQXQowZYWg5MM",
        "tokenType": "Bearer",
        "expireTime": 1587714289
    }
  • Error Response:

    {
        "status": "error",
        "messages": "Authentication failed"
    }

Test

postman 이용 postman collection json

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.