Commit Graph

53 Commits

Author SHA1 Message Date
Miroslav Bajtoš eb5ef04b6a Remove `loopback.compat.usePluralNamesForRemoting`
The `usePluralNamesForRemoting` was added in January 2014 for users
upgrading from LoopBack 1.5 or older.
2014-07-21 16:56:46 +02:00
Miroslav Bajtoš 50816ebbe3 Fix loopback in PhantomJS, fix karma tests
- Move configuration of Karma unit-tests from `Gruntfile.js` to a
  standalone file (`test/karma.conf.js`).

- Add a new Grunt task `karma:unit-ci` to run Karma unit-tests in
  PhantomJS and produce karma-xunit.xml file that can be consumed
  by the CI server.

- Add grunt-mocha-test, configure it to run unit-tests.

- Add `grunt test` task that runs both karma and mocha tests,
  detects Jenkins to produce XML output on CI server.

- Modify the `test` script in `package.json` to run
  `grunt mocha-and-karma` (an alias for `grunt test`).
  The alias is required to trick `sl-ci-run` to run `npm test`
  instead of calling directly `mocha`.

- Add `es5-shim` module to karma unit-tests in order to provide
  ES5-methods required by LoopBack.

- Fix `mixin(source)` in lib/loopback.js to work in PhantomJS.
  `Object.getOwnPropertyDescriptor()` provided by `es5-shim` does not
  work in the same way as in Node.
2014-06-26 13:30:09 +02:00
Miroslav Bajtoš d2517d8236 Merge branch 'master' into 2.0 2014-06-14 09:40:57 +02: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š d21669b844 Merge branch 'master' into 2.0
Conflicts:
	docs.json
	lib/application.js
	lib/loopback.js
	lib/models/data-model.js
	lib/models/model.js
	lib/models/user.js
	lib/registry.js
	package.json
	test/app.test.js
2014-06-13 10:09:25 +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š 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š b576639d90 Add loopback.version back
Add `loopback.version` that was accidentaly removed by #308.
2014-06-10 11:19:36 +02:00
Miroslav Bajtoš eac231df99 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-06 11:53:23 +02:00
Miroslav Bajtoš 51e977de9b lib/loopback: fix jsdoc comments
Use
     @property {Object} [properties]
instead of
     @property {Object=} properties
for optional properties.

Use `**example**` instead of `@example`, since strong-docs don't support
the latter.
2014-06-06 10:28:21 +02:00
Miroslav Bajtoš 5f1c3a86eb Merge pull request #304 from strongloop/feature/createModelFromConfig
[2.0] Add createModelFromConfig and configureModel()
2014-06-06 10:27:03 +02:00
Miroslav Bajtoš f844459311 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 with loopback 1.x,
`app.model(name, config)` calls both `createModelFromConfig`
and `configureModel`.
2014-06-05 17:47:28 +02:00
Miroslav Bajtoš ea5b9d16fc Rename DataModel to PersistedModel 2014-06-05 09:56:00 +02:00
Miroslav Bajtoš 88a4bb462e Exclude express-middleware from browser bundle
Fix lib/loopback to include express-middleware only on the server.

Bump up strong-remoting dependency to use the version working in
browsers.
2014-06-03 21:32:27 +02:00
Raymond Feng bb0ddb26ec Rename express-wrapper to express-middleware 2014-05-29 10:18:58 -07:00
Raymond Feng 49380e490f Upgrade to Express 4.x 2014-05-29 08:44:05 -07:00
Miroslav Bajtoš 18fd61a546 Merge branch 'master' into 2.0 2014-05-28 18:41:36 +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š 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
Ritchie Martori eec7bdd5f4 - Use the RemoteObjects class to find remote objects instead of
creating a cache
 - Use the SharedClass class to build the remote connector
 - Change default base model from Model to DataModel
 - Fix DataModel errors not logging correct method names
 - Use the strong-remoting 1.4 resolver API to resolve dynamic remote
methods (relation api)
 - Remove use of fn object for storing remoting meta data
2014-05-19 15:56:26 -07:00
Ritchie Martori e86a00de69 Merge branch master 2014-04-15 12:53:00 -07:00
Ritchie Martori 5298834c68 Merge branch 'master' into feature/remoting-connector 2014-04-14 11:01:20 -07:00
crandmck 006aca6b9c Update and cleanup JSDoc 2014-04-02 15:46:39 -07:00
Ritchie Martori dcdbef861e Add Remote connector 2014-03-27 14:47:29 -07:00
Ritchie Martori 57ff242308 Minor doc fix 2014-03-10 18:05:44 -07:00
Ryan Graham 088c2e2296 Merge fixup 2014-02-19 14:11:16 -08:00
Ritchie Martori 138821cf8b Merge package.json and lib/loopback.js 2014-02-19 11:44:44 -08:00
Raymond Feng 46b579dc4a Make sure User/AccessToken relations are set up by default
User.login assumes the relation User.accessTokens exists
2014-02-14 10:31:30 -08:00
Ritchie Martori e7f64a3abf Add karma for running browser tests 2014-02-12 10:17:02 -08:00
Miroslav Bajtoš b13ff35697 Make app.models unique per app instance
Remove a source of confusion in unit-tests.
2014-02-04 20:28:19 +01:00
Miroslav Bajtoš 20766e251a Add loopback.compat to simplify upgrade to 1.6
Add a compatibility layer that allows applications based on LB pre-v1.6
to work with 1.6 versions with a minimum amount of changes required.

New flag(s):
  compat.usePluralNamesForRemoting
2014-01-27 10:29:57 +01:00
Ritchie Martori 4be3395298 Add Change model 2014-01-26 13:20:19 -08:00
Raymond Feng bcc7e68e0e Add lookback.getModelByType() and use it resolve model deps 2014-01-23 14:39:27 -08:00
Raymond Feng 8a114c635f Prevent autoAttach from overriding existing data source 2014-01-20 14:32:47 -08:00
Raymond Feng 5a6155e08e Clean up loopback.js doc and add it to docs.json 2014-01-17 10:40:41 -08:00
Raymond Feng 32bdce53ee Fix the jsdoc for loopback.getModel() 2014-01-17 10:23:59 -08:00
Ritchie Martori e7cc30ee03 Fix base class not being actual base class 2013-12-09 17:11:01 -08:00
Ritchie Martori 2f9403016c Initial auth implementation 2013-11-22 12:26:59 -08:00
Ritchie Martori aaa8423257 Fix minor autoWiring bugs 2013-11-20 14:18:54 -08:00
Ritchie Martori 9db8a7a25f Auto attach all models created 2013-11-19 12:23:02 -08:00
Ritchie Martori 178e5dab30 Remove .attachTo() from tests 2013-11-19 11:02:43 -08:00
Ritchie Martori da0545bed6 Initial auto wiring for model dataSources 2013-11-18 16:13:40 -08:00
Raymond Feng 9fddbc3834 Switch to modelBuilder 2013-11-15 11:16:20 -08:00
Raymond Feng 8381b05da1 Allows LDL level ACLs 2013-11-15 09:41:26 -08:00
Raymond Feng 67b934357b Start to build the ACL models 2013-11-14 21:19:56 -08:00
Ritchie 77a137eca6 Rename Session => AccessToken 2013-11-14 10:05:13 -08:00
Raymond Feng a00645dd83 Merge pull request #53 from strongloop/apns
Update Application model for the push notification
2013-11-06 11:50:56 -08:00
Raymond Feng 71339e159e Remove the proxy as it is now handled by the juggler 2013-10-24 20:40:33 -07:00
Raymond Feng bfffd839a7 Update Application model for the push notification 2013-10-11 13:56:26 -07:00
Raymond Feng 0d405d4292 Rename 'loopback-data' to 'loopback-datasource-juggler' 2013-07-30 14:26:49 -07:00