Commit Graph

81 Commits

Author SHA1 Message Date
Miroslav Bajtoš 70615696cd Mark `app.boot` as deprecated. 2014-06-25 13:44:07 +02: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š 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š 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
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
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
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š 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
Ritchie Martori 7c0a470d64 Add basic Remote connector e2e test 2014-04-14 12:25:41 -07:00
crandmck dff182ed27 Clean up JSDoc comments. Remove doc for deprecated installMiddleware function 2014-04-03 11:29:00 -07:00
crandmck a265d67007 Cleanup and update of jsdoc 2014-04-02 15:15:21 -07:00
Ritchie Martori a08b047fab Add hidden property documentation 2014-03-27 15:25:37 -07:00
Ritchie Martori c521b3c386 Allow app.model() to accept a DataSource instance 2014-03-21 12:18:00 -07:00
Raymond Feng 32a9131004 Pause the req before checking access
See https://github.com/strongloop/loopback-storage-service/issues/7
2014-03-17 14:40:05 -07:00
Ritchie Martori 4e437586ed Merge pull request #192 from strongloop/fix/port-zero
Remove coercion from port check
2014-02-21 10:08:27 -08:00
Raymond Feng 37646fa008 Allows options to be passed to strong-remoting 2014-02-19 15:14:31 -08:00
Ritchie Martori 500703e1fb Remove coercion from port check 2014-02-18 16:54:40 -08:00
Guilherme Cirne b466bb96c8 The simplest possible solution for clearing the handler cache when registering a model. 2014-02-18 17:40:35 -03:00
Aurelien Chivot c216ba03c1 Documentation (generated) fix 2014-02-11 19:14:04 +01:00
Miroslav Bajtoš 38f4748021 Add app.isAuthEnabled.
The flag is set by `app.enableAuth` and can be used to detect
whether the access control is enabled.
2014-02-05 18:46:22 +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
Miroslav Bajtoš 8bb8861ba1 Register exported models using singular names
Remove the inconsistency between model names used by LoopBack app and
datasource-juggler (modelName, e.g. User) and the name used by
strong-remoting (pluralModelName, e.g. Users).

This way the class name in the strong-remoting metadata can be used
by client-code generators. Before this change, the generators would
produce method names like `Users.login`.
2014-01-27 10:29:57 +01:00
Miroslav Bajtoš e6cdeb5cd4 Improve jsdox documentation of app object
Remove docs/api-app.md and docs/api.md, as they are no longer referenced
from docs.json.

Add few missing bits from docs/api-app.md to lib/application.js
comments.
2014-01-15 08:44:49 +01:00
Ritchie Martori 9fc8e197ee Start to move md to jsdoc 2014-01-14 10:03:47 -08:00
Miroslav Bajtoš 8573d01c16 Replace `on` with `once` in middleware examples
Fix the jsdox for `app.installMiddleware` to use `app.once` for
listening on 'middleware:*' events.

The previous doc version using `on` was a sort of preliminary
pessimisation, becase the event handlers would stay in the heap
for the whole life-time of the app, even though they won't be called
more than once.
2014-01-14 08:07:47 +01:00
Miroslav Bajtoš ed81bdb6b8 Implement app.installMiddleware
The implementation is mostly a copy of
    loopback-workspace/templates/app.js
2014-01-13 17:26:24 +01:00
Miroslav Bajtoš 914ac2dcc9 Implement `app.listen`
The method starts a http server on the host & port configured
in the app config.
2014-01-13 09:12:54 +01:00
Miroslav Bajtoš 92896a441c Add app.restApiRoot setting
Allow loopback users to configure API root via config file, instead of
editing app.js generated by loopback-workspace.

Allow loopback plugins to discover the path where the REST adapter is
mounted.
2014-01-07 16:05:48 +01:00
Ritchie Martori 981bdd4c81 app.boot() now loads the "boot" directory 2013-12-18 21:41:41 -08:00
Ritchie Martori 5a154072a1 Merge pull request #96 from strongloop/feature/config
Make all app config values available from `app.get()`
2013-12-12 16:01:43 -08:00
Ritchie Martori 4619a143f5 Dont attempt access checking on models without a check access method 2013-12-11 19:46:56 -08:00
Ritchie Martori ea7c9216d7 App config settings are now available from app.get() 2013-12-11 19:31:16 -08:00
Ritchie Martori 4560ec0964 Various ACL fixes 2013-12-10 21:49:18 -08:00
Ritchie Martori dfcb43e613 Allow requests without auth tokens 2013-12-10 15:57:55 -08:00
Ritchie Martori bc27f07472 Add Model.requireToken for disabling token requirement 2013-12-06 12:09:52 -08:00
Ritchie Martori 4c69af5ae2 Add Model.requireToken, default swagger to false 2013-12-06 12:00:18 -08:00
Ritchie 68ef03e944 SLA-725 support PORT and HOST environment for PaaS support 2013-12-05 20:00:09 -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 e5a55846e8 Merge pull request #69 from strongloop/datasource-auto-wiring
Initial auto wiring for model dataSources
2013-11-19 13:11:54 -08:00
Ritchie Martori 9db8a7a25f Auto attach all models created 2013-11-19 12:23:02 -08:00
Ritchie Martori ec58237f8a Add public flag checking 2013-11-18 12:52:00 -08:00
Ritchie 77a137eca6 Rename Session => AccessToken 2013-11-14 10:05:13 -08:00