Creating the Register Endpoint
Learn how to create a register endpoint to register a user.
We'll cover the following...
We'll cover the following...
Create the endpoint logic
With the business logic and data accessing logic ready, the only thing missing is the endpoint that the user can call to register itself.
For the register request, we’ll implement a POST request with endpoint /api/users/register, expecting a JSON object with a property named user containing two properties, username and password.
The first thing we’ll have to do is declare that our createServer function in src/web/index.ts will depend on the UserController interface to be injected. Let’s get started:
- In
src/users/types.ts, create theUserControllerinterface. Make sure it’s also exported insrc/users/index.ts: