FAQ - GovRight/loopback-faq GitHub Wiki
Routes
Regarding custom routes
Q: I've changed the Loopback
restApiRoot
property to/
and now my custom routes (Passport auth routes, or other Express middleware routes) aren't working!
A: Ensure that your custom routes are initializing before loopback.rest
(which initializes by default in a boot script). Loopback will throw back a 404 for invalid routes like /api/InvalidModel
. It doesn’t allow for fallback to later routes.
Misc
Q. My model.js file has become large and unwieldy. How can I split it into separate files?
A: See the following gist: https://gist.github.com/doublemarked/7658a16d0f8f6420df8e
Q: How can I create a property that behaves like an enum?
A: Use a String property validated with validatesInclusionOf
. For example,
User.validatesInclusionOf('gender', {in: ['male', 'female']});