Page Contents

General questions

StrongLoop supports the following operating systems:

  • Red Hat Enterprise Linux (RHEL)/CentOS 6.3 (RPM)
  • RHEL 6 and RHEL 7 on IBM z systems
  • Debian/Ubuntu 12.10 (DEB)
  • SUSE Linux Enterprise Server 11 and 12 on IBM z systems (with Node 0.12.7 and 4.2.2)
  • Mac OS X Mountain Lion 10.8 (PKG)
  • Microsoft Windows 8, 2008 (MSI) NOTE: Node does not support using Cygwin. Instead use Windows Command Prompt for command-line tools.

Is LoopBack free? How much does it cost?

LoopBack is an open-source project that is available for free (without support) and a commercial version with full support is also available as part of IBM API Connect.

Is there a developer forum or mailing list?

Yes! The LoopBack Google Group is a place for developers to ask questions and discuss LoopBack and how they are using it. Check it out!

There is also a LoopBack Gitter channel for realtime discussions with fellow LoopBack developers.

StrongLoop also publishes a blog with topics relevant to LoopBack. See Blog posts for a list of the latest posts.

What client SDKs does LoopBack have?

LoopBack has three client SDKs for accessing the REST API services generated by the LoopBack framework:

  • iOS SDK (Objective C) for iPhone and iPad apps. See iOS SDK for more information.
  • Android SDK (Java) for Android apps. See Android SDK for more information.
  • AngularJS (JavaScript) for HTML5 front-ends. See AngularJS JavaScript SDK for more information.

Which data connectors does LoopBack have?

LoopBack provides numerous connectors to access enterprise and other backend data systems.

Database connectors:

Other connectors:

Additionally, there are community connectors created by developers in the LoopBack open source community.

Why do curl requests to my LoopBack app fail?

If the URL loads fine in a browser, but when you make a curl request to your app you get the error:

curl: (7) Failed to connect to localhost port 3000: Connection refused

The cause is likely to be because of incompatible IP versions between your app and curl.

LoopBack, by default uses IP v4, and curl might be using IP v6. If you see IP v6 entries in your hosts file (::1 localhost, fe80::1%lo0 localhost), it is likely that curl is making requests using IP v6. To make request using IP v4, specify the --ipv4 option in your curl request as shown below.

$ curl http://localhost:3000 --ipv4

You can make your LoopBack app use IP v6 by specifying an IP v6 address as shown below:

app.start = function() {
  // start the web server
  return app.listen(3000, '::1',function() {
    app.emit('started');
    console.log('Web server listening at: %s', app.get('url'));
  });
};

Detailed questions

Once you start working with LoopBack, you may have more detailed questions. Some of the most common are collected here, along with brief answers and links to the documentation for more information.

How do you perform a GET request to a remote server?

First, you have to configure a data source using the REST connector. In the datasources.json file that configures the data source, you can define operations against the REST API using the operations property.

For a short example, see loopback-example-rest-connector.

Can an application respond to a request with XML instead of JSON?

Yes: in in server/config.json set the remoting.rest.xml property to true. See config.json for more information.

How do you send email from an application?

In brief:

  1. Configure a datasource to use the email connector.
  2. Map the built-in Email model to the the email datasource.
  3. Send an email using the configured model with Email.send().

See loopback-example-app-logic for a short example.

How do you use static middleware?

Static middleware enables an application to serve static content such as HTML, CSS, images, and client JavaScript files. To add it:

  1. Remove the contents of the default "routes" property in middleware.json.
  2. Add the following to the "files" property in middleware.json: to serve static content from the project’s /client directory.

    "loopback#static": {      
      "params": "$!../client"
    }
    

    Of course, change the value to use a different directory to contain static content.

See Defining middleware for more information, and loopback-example-middleware for a short example.

What kind of hooks do models support?

LoopBack models support:

  • Operation hooks that execute when the model performs CRUD (create, read, update, and delete) operations.
  • Remote hooks  that execute before or after a remote method is called.

Does LoopBack support JavaScript configuration files (not just JSON)?

Yes, LoopBack does support overriding the default .json files with .js files. See the page on environment-specific configuration for details.

User management questions

See Managing users for more information and  loopback-example-user-management for relevant code examples.

Note

How do you register a new user?

  1. Create a form to gather sign up information.
  2. Create a remote hook to  send a verification email.

Notes:

  • Upon execution, user.verify sends an email using the provided  options.
  • The verification email is configured to  redirect the user to the /verified route in our example. For your app, you should configure the redirect to match your use case.
  • The options are self-explanatory except typetemplate and user.
    • type - value must be email.
    • template - the path to the template to use for the verification email.
    • user - when provided, the information in the object will be used to in the verification link email.

How do you send an email verification for a new user registration?

See step 2 in the previous question.

How do you log in a user?

  1. Create a form to accept login credentials.
  2. Create an route to handle the login request.

How do you log a user out?

  1. Create a logout link with the access token embedded into the URL.
  2. Call User.logout with the access token.

Notes:

  • We use the loopback token middleware to process access tokens. As long as you provide access_token in the query string of URL, the access token object will be provided in req.accessToken property in your route handler.

How do you perform a password reset for a registered user?

  1. Create a form to gather password reset information.
  2. Create an endpoint to handle the password reset request. Calling User.resetPassword ultimately emits a resetPasswordRequest event and creates a temporary access token.
  3. Register an event handler for the resetPasswordRequest that sends an email to the registered user. In our example, we provide a URL that redirects the user to a password reset page authenticated with a temporary access token.
  4. Create a password reset form  for the user to enter and confirm their new password.
  5. Create an endpoint to process the password reset.

Note: For the resetPasswordRequest handler callback, you are provided with an  info  object which contains information related to the user that is requesting the password reset.

Note: Do not forget to configure the bodyParser and use loopback.token() in your app. You can see examples in server.js