Creating the Register Endpoint

Learn how to create a register endpoint to register a user.

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:

  1. In src/users/types.ts, create the UserController interface. Make sure it’s also exported in src/users/index.ts:

Get hands-on with 1400+ tech skills courses.