Search code examples
loopbackjsstrongloop

lower case model endpoints (user instead of User)


I'd like my REST API endpoints to use all lower case letters for the model.

In the case of the built-in User model, would I simply make a new model named user with User as the base? or is there another method I should use?


Solution

  • There are a few options:

    1. At the moment, the endpoint name is case-insenstive, i.e., /api/users and /api/Users both work.
    2. You can customize the model endpoint name in the model definition json, for example

      "http": {"path": "/my-users"}

    3. There are a pending PR: https://github.com/strongloop/loopback/pull/433

    4. As Simon pointed out, you can subclass the User model. Please the default endpoint name is derived from the plural of the model name.