Migrating Actio sample project from Udemy to .NET Core 3.0
Anton Yarkov: https://github.com/optiklab/actio is the project created by guidelines from Udemy course about .NET microservices and CQRS pattern. https://github.com/optiklab/actio_3.0 is the same project, but migrated to .NET 3.0.
https://rawrabbit.readthedocs.io/en/master/ https://rawrabbit.readthedocs.io/en/master/configuration.html
- Run mongo db instance:
$>docker run -d -p 27017:27017 mongo- Go to Api project and run on HTTP port 5000:
$>dotnet run- Go to Activities project and run on HTTP port 5005:
$>dotnet run --urls "http://+:5005"Result: Check that default Categories collection is created in MongoDb
- Go to Identity project and run on HTTP port 5050:
$>dotnet run --urls "http://+:5050"- Run Postman and execute to create an Activity inside of existing Category:
POST http://localhost:5000/activities HTTP/1.1
Host: localhost:5000
Content-Type: application/json
cache-control: no-cache
body:
{
"category": "hobby",
"name": "blah blah1"
}Result: Check that Activity is created in MongoDb
- Run Postman and execute to create first user:
POST http://localhost:5000/users/register HTTP/1.1
Host: localhost:5000
Content-Type: application/json
cache-control: no-cache
body:
{
"email":"[email protected]",
"name":"anton",
"password":"test1234"
}
Result: Check that User is created in MongoDb- Run Postman and execute:
GET http://localhost:5000/activities HTTP/1.1
Host: localhost:5000
Response: 401 unauthorized- Run Postman and execute:
POST http://localhost:5050/login HTTP/1.1
Host: localhost:5050
Content-Type: application/json
cache-control: no-cache
body:
{
"email":"[email protected]",
"password":"test1234"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJiNmM3MDZhNi1jOGI5LTQ4NGItOTIzMC0zNjU2Y2UzM2JiOTMiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjUwNTAiLCJpYXQiOjE1NzIxMjk5MzcsImV4cCI6MTU3MjEzMDIzNywidW5pcXVlX25hbWUiOiJiNmM3MDZhNi1jOGI5LTQ4NGItOTIzMC0zNjU2Y2UzM2JiOTMifQ.lXQ5rrVyANYFmvIa8s6vJts165U2E7Q8sQtzfEUugjw",
"expires": 1572130237
}You can check content of token on https://jwt.io/
GET http://localhost:5000/activities HTTP/1.1
Host: localhost:5000
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJiNmM3MDZhNi1jOGI5LTQ4NGItOTIzMC0zNjU2Y2UzM2JiOTMiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjUwNTAiLCJpYXQiOjE1NzIxMjk5MzcsImV4cCI6MTU3MjEzMDIzNywidW5pcXVlX25hbWUiOiJiNmM3MDZhNi1jOGI5LTQ4NGItOTIzMC0zNjU2Y2UzM2JiOTMifQ.lXQ5rrVyANYFmvIa8s6vJts165U2E7Q8sQtzfEUugjw
cache-control: no-cache
Response:
HTTP 200 OK
Secured content!- Go to the .vscode in the root and edit launch.json to specify paths to the project to Debug
- Run Start Debugging (don't forget to put breakpoints)
- Create Dockerfile in project directory (separate for each microservice)
- Create appsettings.docker.json with changed parameters of URLs
- Pack your app into docker:
$> \Actio\src\Actio.Api>dotnet publish -c Release -o ./bin/Docker- Build your docker:
$> docker build -t actio.api .- Build your docker:
$> docker run -p 5000:5000 actio.api