I finished! On to the next chapter

Outline

Demo: Create RegisterUser Endpoing

The goal of this demo is to ensure the api endpoint we create works without any problems. Once we get the registration api endpoint working we'll continue adding more code to meet the registration and login requirements.

In the Conduit.Api Project

Modify UsersController
  • Add RegisterUser Post Method
  • Add Models Project Reference

Test that the api is working correctly.

The result of the C# Code:

using Conduit.Models.Requests;
using Conduit.Models.Responses;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace Conduit.Api.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UsersController : ControllerBase
    {
        private ILogger<UsersController> Logger;

        [HttpPost]
        public IActionResult RegisterUser([FromBody]UserRequest<Register> req)
        {
            User user = new User
            {
                Bio = "no bio yet",
                Email = req.User.Email,
                Image = "no image yet",
                Token = "no token yet",
                UserName = req.User.UserName
            };
            return Ok(new { user });
        }

        public UsersController(ILogger<UsersController> logger)
        {
            Logger = logger;
        }
    }
}

Conduit Github Repo

Tag Name: working_api