이 저장소에는 보호 된 WebAPI를 소비하는 관리 프론트 엔드를위한 .NET MAUI 애플리케이션 인 JWT 인증을 구현하는 ASP.NET Core WebAPI 응용 프로그램이 포함되어 있습니다.
repository
|__src
| |__Foody -> web api project
| |__client -> maui project
| |__.gitignore
|__.gitignore
|__ReadME.md
프로젝트는 로컬 또는 코드 스페이스에서 실행할 수 있습니다.
설치할 일부 요구 사항 및 워크로드 :
명령 프롬프트 (Windows) 또는 터미널 (Mac)을 열고 Repository를 복제하십시오.
git clone https://github.com/coderBane/food-web-app.git
코드 드롭 다운 메뉴를 클릭하고 코드 스페이스를 선택하여 코드 스페이스에서 리포지토리를 엽니 다.
프로젝트를 실행하기 전에 먼저 몇 가지 사항을 설정해야합니다.
dotnet ef 설치하십시오 dotnet tool install -- global dotnet - efRedis 컨테이너 인스턴스를 만듭니다
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
프로젝트를 실행하기 전에 웹 API에 대한 몇 가지 사항을 구성해야합니다. foody.webapi.csproj 파일을 열고 usersecretsid 속성을 삭제하십시오.
새 터미널 또는 명령 프롬프트를 열고 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
이제 프로젝트를 실행할 수 있습니다
Swagger없이 시작합니다
dotnet run
Swagger UI와 함께 출시
dotnet watch