Giter VIP home page Giter VIP logo

go-todolist's Introduction

Project description

這是一個簡單的待辦事項專案
備註:

  1. jwt-token TTL 時間預設 900 秒,中介層驗證 token TTL 成功時,計算該 token TTL 是否低於 5 分鐘,低於則重新給予一組新的 token。
  2. token 加入白名單機制,經由 redis 管理,使用者登出一併清除 redis token。
  3. 日誌輸出,預設採用日期分割檔案,如果需要按容量大小分割檔案請取消註解 utils/log/logBySize.go

It is a simple todo list project
Note:

  1. jwt-token TTL time is preset to 900 seconds. When the middleware verifies the success of token TTL, it will calculate whether the token TTL is lower than 5 minutes, and if it is lower, a new set of token will be given again.
  2. The token is added to the whitelist mechanism, managed by redis, and the user logout to clear the redis token as well.
  3. Log output, default date split file, if you need to split the file by size please uncomment utils/log/logBySize.go.

Project plugins

How to build

Install migrate

https://github.com/golang-migrate/migrate/tree/master/cmd/migrate

Generate vendor and migrations

go mod vendor

# Up migration
# migrate -database "mysql://{user}:{password}@tcp({host}:{port})/{project name}" -path ./migrations up
migrate -database "mysql://root:@tcp(127.0.0.1:3306)/go-todolist" -path ./migrations up

# Down migration
# migrate -database "mysql://{user}:{password}@tcp({host}:{port})/{project name}" -path ./migrations down
migrate -database "mysql://root:@tcp(127.0.0.1:3306)/go-todolist" -path ./migrations down

# Specify batch up or down (If you want to go down to a specific file, it is recommended to open a new folder)
# migrate -database "mysql://{user}:{password}@tcp({host}:{port})/{project name}" -path ./migrations up {number}
migrate -database "mysql://root:@tcp(127.0.0.1:3306)/go-todolist" -path ./migrations up 1
# migrate -database "mysql://{user}:{password}@tcp({host}:{port})/{project name}" -path ./migrations down {number}
migrate -database "mysql://root:@tcp(127.0.0.1:3306)/go-todolist" -path ./migrations down 1

Run go

go run main.go

Folder structure

├── LICENSE
├── README.md
├── controller
│   ├── categoryController.go
│   ├── googleOauthController.go
│   └── userController.go
├── entity
│   ├── categoryEntity.go
│   ├── redisEntity.go
│   └── userEntity.go
├── go.mod
├── go.sum
├── log
│   ├── error-20230123.log
│   ├── error.log -> error-20230123.log
│   ├── info-20230118.log
│   ├── info-20230119.log
│   ├── info-20230123.log
│   ├── info-20230124.log
│   ├── info-20230125.log
│   ├── info-20230129.log
│   ├── info-20230130.log
│   └── info.log -> info-20230130.log
├── main.go
├── middleware
│   ├── cors.go
│   ├── jwt.go
│   └── rateLimiter.go
├── migrations
│   ├── 20221129000000_create_users_table.down.sql
│   ├── 20221129000000_create_users_table.up.sql
│   ├── 20221129000001_create_categories_table.down.sql
│   ├── 20221129000001_create_categories_table.up.sql
│   ├── 20221129000002_create_tasks_table.down.sql
│   ├── 20221129000002_create_tasks_table.up.sql
│   ├── 20221129000003_create_category_task_table.down.sql
│   └── 20221129000003_create_category_task_table.up.sql
├── model
│   ├── category.go
│   └── user.go
├── request
│   ├── categoryRequest.go
│   ├── publicRequest.go
│   └── userRequest.go
├── router
│   └── api.go
├── services
│   ├── jwtService.go
│   └── userService.go
├── tmp
│   ├── build-errors.log
│   └── main
└── utils
    ├── gorm
    │   ├── gorm.go
    ├── log
    │   ├── logByDate.go
    │   └── logBySize.go
    ├── paginator
    │   └── paginator.go
    ├── redis
    │   └── redis.go
    └── responses
        └── response.go

Folder definition

  • Controller

接收 HTTP request 調用 request & service
Receiving HTTP requests calling requests and services

  • Entity

協助 service 調用 sql query
Assist service in calling sql query

  • Log

日誌檔位置
Location of logger files

  • Middleware

中介層,負責過濾進入的資料
Intermediary layer, responsible for filtering incoming data

  • Migration

建立 datatable 詳細資訊
Create datatable details

  • Model

作為返回的對象
As a returned object

  • Request

協助 controller 驗證 request parameters
Assist controller validation request parameters

  • Router

API 路由位置
API route locations

  • Service

協助 controller 處理業務邏輯
Assist controller with business logic

  • Utils

模組化程式碼置放處,提供專案調用
Modular code placement for project calls

go-todolist's People

Contributors

frankie0702111 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.