Commit Graph

293 Commits

Author SHA1 Message Date
Miroslav Bajtoš f05291ca93 registry: fix non-unique default dataSources
Fix the problem where `registry.defaultDataSources` has two instances:

 - `require('loopback').defaultDataSources` used by
   `loopback.autoAttach()`

 - `require('./registry').defaultDataSources` used by
   `app.dataSource`.

I am intentionally leaving out unit-tests as the whole `autoAttach`
feature is going to be deleted before 2.0 is released.
2014-06-12 10:41:45 +02:00
Miroslav Bajtoš 362cceb70a Merge createModelFromConfig with createModel
Merge the two methods `loopback.createModel` and
`loopback.createModelFromConfig` into a single method `createModel`.
2014-06-12 10:41:45 +02:00
Miroslav Bajtoš 7cd6e09790 lib/registry fix jsdoc comments
Add missing names.
2014-06-12 10:41:44 +02:00
Miroslav Bajtoš 7d674779e1 refactor: extract runtime and registry
Move isBrowser and isServer from lib/loopback to a new file lib/runtime.

Move all Model and DataSource related methods like `createModel` and
`createDataSource` to lib/registry.

Remove the circular dependency between lib/application and lib/loopback,
by loading lib/registry and/or lib/runtime instead of lib/loopback
where appropriate

This commit is only moving the code around, the functionality should
not be changed at all.
2014-06-12 10:41:44 +02:00
Miroslav Bajtoš 19425b8fd9 Remove assertIsModel and isDataSource
Use `instanceof` operator instead:

  ModelCtor.prototype instanceof loopback.Model
  dataSource instanceof loopback.DataSource
2014-06-12 10:41:44 +02:00
Miroslav Bajtoš fc0fad4a9f Add createModelFromConfig and configureModel()
Add new API allowing developers to split the model definition and
configuration into two steps:

 1. Build models from JSON config, export them for re-use:

  ```js
  var Customer = loopback.createModelFromConfig({
    name: 'Customer',
    base: 'User',
    properties: {
      address: 'string'
    }
  });
  ```

 2. Attach existing models to a dataSource and a loopback app,
    modify certain model aspects like relations:

  ```js
  loopback.configureModel(Customer, {
    dataSource: db,
    relations: { /* ... */ }
  });
  ```

Rework `app.model` to use `loopback.configureModel` under the hood.
Here is the new usage:

```js
var Customer = require('./models').Customer;

app.model(Customer, {
  dataSource: 'db',
  relations: { /* ... */ }
});
```

In order to preserve backwards compatibility,
`app.model(name, config)` calls both `createModelFromConfig`
and `configureModel`.
2014-06-12 10:41:44 +02:00
Miroslav Bajtoš 4259a3862a Make app.get/app.set available in browser
Implement settings object and methods in browser-express.
2014-06-12 10:40:36 +02:00
crandmck ad347e517c JSDoc fixes 2014-06-11 14:55:47 -07:00
Raymond Feng 7769174d58 Tidy up app.model() to remove duplicate & recusrive call 2014-06-09 23:53:01 -07:00
Raymond Feng 815ad53aa4 Register existing model to app.models during app.model() 2014-06-09 16:31:33 -07:00
crandmck 6af69e322a JSDoc cleanup 2014-06-09 15:50:04 -07:00
crandmck cea2d30928 Merge branch 'master' of github.com:strongloop/loopback 2014-06-09 15:42:07 -07:00
crandmck 1694ee2d83 JSDoc cleanup 2014-06-09 15:36:08 -07:00
Raymond Feng 854402acba Merge pull request #314 from strongloop/feature/allow-custom-token-creation
Allow the creation of access token to be overriden
2014-06-09 15:01:15 -07:00
Raymond Feng a6ff4b0cad Use constructor to reference the model class 2014-06-09 15:00:15 -07:00
Raymond Feng 6b4ebdf609 Allow the creation of access token to be overriden 2014-06-09 14:53:55 -07:00
crandmck 1316676946 Fixup JSDocs; note: updateOrCreate function alias pulled out on separate line for docs 2014-06-06 17:17:37 -07:00
crandmck d8c6f9d962 Update JSDoc 2014-06-04 17:42:18 -07:00
Ritchie Martori fea1cee1c4 !fixup only set ctx.accessType when sharedMethod is available 2014-06-02 14:41:08 -07:00
Ritchie Martori a2f931ed3f Refactor ACL to allow for `methodNames` / aliases 2014-06-02 14:41:08 -07:00
Miroslav Bajtoš acf7af0c4e Merge pull request #287 from strongloop/feature/connector-registry
app: implement `connector()` and `connectors`
2014-05-28 17:01:24 +02:00
Miroslav Bajtoš 94ec5c294a app: implement `connector()` and `connectors`
Allow browserified applications to explicitly register connectors
to use in data-sources via `app.connector(name, exportsFromRequire)`.

Include built-in connectors like `Memory` and `Remote` in the registry.

Modify `dataSourcesFromConfig()` to resolve the connector via
`app.connectors` first and only then fall back to auto-require
the connector module.
2014-05-28 15:11:43 +02:00
Miroslav Bajtoš d0c87d3420 Merge pull request #285 from STRML/fixRestApiRootTypo
Fix a typo in `app.boot` caused by the change from restBasePath to restApiRoot.
2014-05-28 14:56:46 +02:00
Samuel Reed e625028486 Fix a typo in `app.boot`.
This typo was caused by the change from restBasePath to restApiRoot.

Signed-off-by: Samuel Reed <sam@tixelated.com>
2014-05-28 17:25:41 +08:00
Miroslav Bajtoš 7cfe450161 Make app.datasources unique per app instance
This removes a source of confusion in unit-tests.
2014-05-27 14:33:42 +02:00
Miroslav Bajtoš 227c2d05cd app: flatten model config
Support flat structure of model config objects, where model options
are set as top-level properties.

Before:

    Customer: {
      dataSource: 'db',
      options: {
        base: 'User'
      }
    }

Now:

    Customer: {
      dataSource: 'db',
      base: 'User'
    }
2014-05-27 08:10:20 +02:00
Miroslav Bajtoš bfb154d445 Modify `loopback.rest` to include `loopback.token`
Make `loopback.rest` self-contained, so that authentication works
out of the box.

    var app = loopback();
    app.enableAuth();
    app.use(loopback.rest());

Note that cookie parsing middleware is not added, users have to
explicitly configure that if they want to store access tokens
in cookies.

Modify `loopback.token` to skip token lookup when the request already
contains `accessToken` property. This is in line with other
connect-based middleware like `cookieParser` or `json`.
2014-05-21 15:22:36 +02:00
Adam Schwartz 7c00119292 Fix typo "Unkown" => "Unknown" 2014-05-15 23:32:12 -04:00
haio 978bc57421 Fix bug in User#resetPassword 2014-05-10 15:43:01 +08:00
haio 429052a0db Ensure roleId and principalId to be string in Role#isInRole 2014-05-03 11:43:03 +08:00
haio eae86b64f4 typo 2014-04-29 20:10:44 +08:00
haio f44d737e7e Add more check on principalId 2014-04-29 09:34:48 +08:00
haio aa63d7bf4b Convert principalId to String 2014-04-28 21:36:44 +08:00
Raymond Feng b57c998ce2 Merge pull request #242 from strongloop/feature/fix-issue-239
Rename the method so that it won't conflict with Model.checkAccess
2014-04-24 10:27:18 -07:00
crandmck 1676ac6e58 Fix constructor JSDoc 2014-04-23 15:20:18 -07:00
Raymond Feng 921e35954d Rename the method so that it won't conflict with Model.checkAccess
See https://github.com/strongloop/loopback/issues/239
2014-04-21 11:13:03 -07:00
Ritchie Martori 13b18065e2 Documentation cleanup 2014-04-14 14:49:29 -07:00
Ritchie Martori 940e11125d Fix save implementation for remoting connector 2014-04-14 14:17:56 -07:00
Ritchie Martori 7c0a470d64 Add basic Remote connector e2e test 2014-04-14 12:25:41 -07:00
Ritchie Martori 5298834c68 Merge branch 'master' into feature/remoting-connector 2014-04-14 11:01:20 -07:00
Ritchie Martori 63ad8f69ae Add test for remoting nested hidden properties 2014-04-11 11:43:37 -07:00
Alex Pica 1c1364636d Fix #229 (Whitespaces removed 2014-04-10 06:01:58 +03:00
Miroslav Bajtoš e8971fde41 Merge pull request #223 from strongloop/feature/improve-sharedctor-description
Describe the "id" parameter of model's sharedCtor
2014-04-04 07:36:03 -07:00
crandmck dff182ed27 Clean up JSDoc comments. Remove doc for deprecated installMiddleware function 2014-04-03 11:29:00 -07:00
Miroslav Bajtoš 4c246c7f2c Describe the "id" parameter of model's sharedCtor
Extend remoting metadata to describe the "id" parameter accepted
by the sharedCtor of all models.
2014-04-03 10:39:42 +02:00
crandmck 006aca6b9c Update and cleanup JSDoc 2014-04-02 15:46:39 -07:00
crandmck a265d67007 Cleanup and update of jsdoc 2014-04-02 15:15:21 -07:00
Ritchie Martori 5f81fad921 Merge pull request #217 from strongloop/feature/hidden-properties
Feature/hidden properties
2014-03-31 12:04:49 -07:00
Ritchie Martori 51d3ff892a Merge pull request #219 from dougtoppin/fix-verify-confirm
Fix verify confirm
2014-03-31 12:02:48 -07:00
Doug Toppin 8b71c3022d Update user.js
Corrected spacing on confirm ACL, removed extraneous comment on using hex rather than base64
2014-03-30 08:02:19 -04:00