使用 GORM 实现带认证的 Todo 应用
本项目演示了一个使用 GORM 实现带认证的 Todo 应用。
先决条件
请确保你已安装以下软件,并且在你的 GOPATH
中可用
- Golang
- 用于热重载的 Air
- 用于加载
.env
文件的 Godotenv
安装
-
克隆仓库
git clone https://github.com/gofiber/recipes.git
cd recipes/todo-app-with-auth-gorm -
安装依赖
go get
运行应用
- 启动应用
air
环境变量
在根目录下创建 .env
文件并添加以下变量
# PORT returns the server listening port
# default: 5000
PORT=
# DB returns the name of the sqlite database
# default: gotodo.db
DB=
# TOKENKEY returns the jwt token secret
TOKENKEY=
# TOKENEXP returns the jwt token expiration duration.
# Should be time.ParseDuration string. Source: https://golang.ac.cn/pkg/time/#ParseDuration
# default: 10h
TOKENEXP=