tkhquang / example-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Library API excercise

Library API excercise is a golang implement(using go-kit, gorm) of library API

Submitted by: {{github_user_name}}

Time spent: {{time_spent}} hours spent in total

Prerequisite

How to start

  • make local-env: To create local DB(port: 5432), test DB(port:5439), adminer(tools to view database, port:8080)
  • make clean-local-env: Turn off local-env (be careful it will also clear DB)
  • make dev: To start server (default port is 3000)
  • make test: To run test (both integration and unit test)

User Stories

Required:

  • NOTE: Each main point should follow git flows (each step should have a feature branch,...)

Stage 1:

  • API must be able to CRUD users:

    • Each user should have the following fields:
      • id (uuid)
      • name (string)
      • email (string)
    • API must be able to get detail of a user.
    • API must be able to get list of users
    • API must be able to create a user
    • API must be able to update a user
    • API must be able to delete a user
  • Validate user is correct before (Create/Update):

    • validate name of user is not empty.
    • validate email of user is not empty.
    • validate email of user is a valid email.
  • API must be able to CRUD category of books:

    • Each category should have the following fields:
      • id (uuid)
      • name (string)
    • API must be able to get detail of a category.
    • API must be able to get list of categories.
    • API must be able to create a category.
    • API must be able to update a category.
    • API must be able to delete a category.
    • when delete categories all book belongs to that categories should deleted too.
  • Validate category is correct before (Create/Update):

    • validate name of category is not empty and length > 5 characters.
    • validate name of category not existed yet (for both create and update).
  • API must be able to CRUD books:

    • Each book should have the following fields:
      • id (uuid)
      • name (string)
      • category_id (uuid)
      • author (string)
      • description (string)
    • API must be able to get detail of a book.
    • API must be able to get list of books.
    • API must be able to create a book.
    • API must be able to update a book.
    • API must be able to delete a book.
  • Validate books is correct before (Create/Update):

    • validate category of a book is exist, if not reject it with error message
    • validate name of a book is not empty and length > 5 characters. if not reject it with error message
    • validate description of a book is not empty and length > 5 characters. if not reject it with error message
  • API must be able to make action: user lend a book:

    • API should have the following fields:
      • id (uuid)
      • book_id (uuid)
      • user_id (uuid)
      • from (datetime)
      • to (datetime)
    • validate book_id of a book is exist, if not reject it with error message
    • validate user_id of a user is exist, if not reject it with error message
    • validate books is available to lend, if not available reject with error message

Stage 2:

  • Add testing for CRUD users:
    • Validation testing (unit test)
    • Endpoint testing (unit test)
    • Database testing (integration)
  • Add testing for CRUD category:
    • Validation testing
    • Database testing
  • Add testing for CRUD books:
    • Validation testing
    • Database testing
  • Add testing for lending books:
    • Validation testing
    • Database testing

Optional:

  • List books and filter by name, availables status.
  • batch create books (create multiple book with 1 API)
  • batch lending books (user can lending multiple books with 1 api)
  • implement feature add a tags to books can search book by tag name
  • implement multiple errors return by an array

The following additional features are implemented:

  • .....

The following known issues:

  • ...

Video Walkthrough

Here's a walkthrough of implemented user stories:

Notes

Notes about current git.

License

Copyright [2018] [{{github_user_name}}]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About


Languages

Language:Go 97.2%Language:Makefile 1.9%Language:TSQL 0.9%