food web app
1.0.0
该存储库包含一个实现JWT身份验证的ASP.NET核心WebAPI应用程序,该应用程序是一个.NET MAUI管理应用程序,用于管理受保护的WebAPI。
repository
|__src
| |__Foody -> web api project
| |__client -> maui project
| |__.gitignore
|__.gitignore
|__ReadME.md
该项目可以在本地或代码空间运行。
某些要求和工作负载要安装:
打开命令提示符(Windows)或终端(MAC),然后输入克隆存储库:
git clone https://github.com/coderBane/food-web-app.git
通过单击“代码下拉菜单”并选择代码空间,在代码空间中打开存储库
在运行项目之前,我们需要先设置一些内容。
dotnet ef dotnet tool install -- global dotnet - ef创建一个redis容器实例
docker run --name redis-cache -p 6379:6379 -d redis
创建一个容器实例
docker run --name postgresql -e POSTGRES_PASSWORD=<yourpassword> -p 5432:5432 -d postgres
运行PSQL
docker exec -it postgresql psql -U postgres
首先,我们需要创建一个新角色。该角色将具有登录和数据库创建特权。
CREATE ROLE devuser WITH LOGIN CREATEDB PASSWORD '<yourpassword>';
切换到新用户
c postgres devuser
创建数据库
CREATE DATABASE foody;
NOTE: You can run the command l to view all existing databases
在运行项目之前,我们需要为Web API配置一些内容。打开foody.webapi.csproj文件,并删除用户交易属性。
打开新的终端或命令提示符,然后将目录更改为foody.webapi文件夹。
运行命令:
dotnet user-secrets init
使用此网站随机生成一个随机字符串。
创建一个新的文件“ S.JSON”并用以下内容填充它
{
"JwtConfig": {
"Secret": "<generatedstring>",
"ExpiryTimeFrame": "00:01:00"
},
"WatchDog": {
"Username": "<yourusername>",
"Password": "<yourpassword>"
},
"Redis": "localhost",
"Postgres": "Server=localhost:5432;Database=foody;User Id=devuser;Password=<devuserpassword>;Integrated Security=true;Pooling=true;",
"UserPW": "<yourpassword>"
}
设置用户秘密
cat ./s.json | dotnet user-secrets set
NOTE: You can delete the s.json file
我们需要在数据库中创建表。
dotnet ef --startup-project ../Foody.WebApi database update
我们现在可以运行项目
不招摇而发射
dotnet run
用Swagger UI启动
dotnet watch