Commit Graph

315 Commits

Author SHA1 Message Date
Raymond Feng c5c28aa634 Merge pull request #368 from strongloop/feature/loopback-base-model
Refactor modelBuilder to registry and set up default model
2014-07-15 08:38:43 -07:00
Raymond Feng 3c13ce5a8f Refactor modelBuilder to registry and set up default model 2014-07-15 08:37:59 -07:00
Raymond Feng 22e929e439 Fix credentials/challenges types
Associated identities and credentials are now captured by models in
loopback-component-passport. These two properties will be removed in
2.x.
2014-07-14 14:22:21 -07:00
crandmck b5c47dc7a5 Split out aliases for deleteById and destroyAll functions for jsdoc. 2014-07-11 15:41:14 -07:00
Raymond Feng de831dbd33 Fix the typo 2014-07-08 08:54:13 -07:00
Raymond Feng 0c67b1e781 Add an option to honor emailVerified
See https://github.com/strongloop/loopback/pull/215
2014-07-07 14:09:45 -07:00
Raymond Feng 217c9fa348 Fix the typo and add Bearer token support
See https://github.com/strongloop/loopback/issues/333
2014-07-02 09:02:13 -07:00
Aleksandr Tsertkov 476dd8214d Fix misleading token middleware documentation
Signed-off-by: Aleksandr Tsertkov <tsertkov@gmail.com>
2014-07-01 16:59:49 +02:00
Miroslav Bajtoš dfa8d7f49f app: update `url` on `listening` event
Most applications report the URL when started (at least the apps we
are scaffolding using loopback-workspace). Constructing the URL in the
loopback core allows us to simplify the templates and reduce the amount
of repeated code.
2014-07-01 14:27:02 +02:00
Miroslav Bajtoš 45d026e7de Merge pull request #335 from karlmikko/bug/invalid-token-unhandled
Ignore unhanded error - simulate token missing
2014-06-27 09:56:17 +02:00
Guilherme Cirne 3fba6c50f0 Fix "ReferenceError: loopback is not defined" in registry.memory().
Signed-off-by: Guilherme Cirne <gcirne@gmail.com>
2014-06-26 10:40:28 -03:00
Karl Mikkelsen 46af483bdd Invalid Access Token return 401
Clean up logic to be easier to read.
Signed-off-by: Karl Mikkelsen <karl@karlmikko.com>
2014-06-26 08:50:41 +10:00
Raymond Feng 70c1cb5ce0 Update debug setting 2014-06-25 09:09:04 -07:00
Miroslav Bajtoš 70615696cd Mark `app.boot` as deprecated. 2014-06-25 13:44:07 +02:00
Samuel Reed afd8de0c31 Fix a slowdown caused by mutation of an incoming accessToken option. 2014-06-20 16:39:28 -05:00
Raymond Feng d5ed57e60d Merge pull request #254 from strongloop/feature/role-id
Set the role id to be generated
2014-06-17 10:37:06 -07:00
Miroslav Bajtoš 843e09342c lib/application: Remove forgotten `loopback` ref
Use `registry.Model` instead of `loopback.Model`.
2014-06-16 09:52:11 +02:00
Miroslav Bajtoš 8826b6396a Merge pull request #306 from karlmikko/master
Ability to return 401 and 403 response codes #301
2014-06-14 09:44:22 +02:00
Karl Mikkelsen a90a5c7e58 Allow customization of ACL http status
emulate existing error on 404
new tests for model and app settings
Signed-off-by: Karl Mikkelsen <karl@karlmikko.com>
2014-06-14 11:31:15 +10:00
Miroslav Bajtoš c4db83ad43 Expose loopback as `app.loopback`
The primary intention is to allow loopback plugins to determine
the version of the loopback framework from the `app` object.
2014-06-13 10:34:51 +02:00
Miroslav Bajtoš 02d1c5e3c2 registry: export DataSource class
Expose the juggler's DataSource constructor as `loopback.DataSource`.

The DataSource constructor is most useful to check
for `instanceof DataSource`, but it also makes the loopback API more
consistent, since the API is already exposing all pre-built Models.
2014-06-12 10:41:45 +02:00
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 6490447fac Set the role id to be generated
See https://github.com/strongloop/loopback-connector-postgresql/issues/5
2014-06-10 16:38:37 -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