diff --git a/README.md b/README.md
index 117b7bd5..c8c3c781 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
-# asteroid
+# loopback
v0.9.0
## Install
- slnode install asteroid -g
+ slnode install loopback -g
## Server API
@@ -12,7 +12,7 @@ v0.9.0
- [Model](#model)
- [DataSource](#data-source)
- [Connectors](#connectors)
- - [Asteroid Types](#asteroid-types)
+ - [Loopback Types](#loopback-types)
- [GeoPoint](#geo-point)
- [REST Router](#rest-router)
- [Bundled Models](#bundled-models)
@@ -26,10 +26,10 @@ _TODO_
### App
-Create an asteroid application.
+Create an loopback application.
- var asteroid = require('asteroid');
- var app = asteroid();
+ var loopback = require('loopback');
+ var app = loopback();
app.get('/', function(req, res){
res.send('hello world');
@@ -48,12 +48,12 @@ Create an asteroid application.
Expose a `Model` to remote clients.
// create a testing data source
- var memory = asteroid.memory();
+ var memory = loopback.memory();
var Color = memory.createModel('color', {name: String});
Color.attachTo(memory);
app.model(Color);
- app.use(asteroid.rest());
+ app.use(loopback.rest());
**Note:** this will expose all [shared methods](#shared-methods) on the model.
@@ -69,10 +69,10 @@ Get the app's exposed models.
### Model
-An Asteroid `Model` is a vanilla JavaScript class constructor with an attached set of properties and options. A `Model` instance is created by passing a data object containing properties to the `Model` constructor. A `Model` constructor will clean the object passed to it and only set the values matching the properties you define.
+An Loopback `Model` is a vanilla JavaScript class constructor with an attached set of properties and options. A `Model` instance is created by passing a data object containing properties to the `Model` constructor. A `Model` constructor will clean the object passed to it and only set the values matching the properties you define.
// valid color
- var Color = asteroid.createModel('color', {name: String});
+ var Color = loopback.createModel('color', {name: String});
var red = new Color({name: 'red'});
console.log(red.name); // red
@@ -88,9 +88,9 @@ A model defines a list of property names, types and other validation metadata. A
Some [DataSources](#data-source) may support additional `Model` options.
-Define an asteroid model.
+Define an loopback model.
- var User = asteroid.createModel('user', {
+ var User = loopback.createModel('user', {
first: String,
last: String,
age: Number
@@ -154,7 +154,7 @@ Validate the model instance.
#### Model.properties
-An object containing a normalized set of properties supplied to `asteroid.createModel(name, properties)`.
+An object containing a normalized set of properties supplied to `loopback.createModel(name, properties)`.
Example:
@@ -163,10 +163,10 @@ Example:
b: {type: 'Number'},
c: {type: 'String', min: 10, max: 100},
d: Date,
- e: asteroid.GeoPoint
+ e: loopback.GeoPoint
};
- var MyModel = asteroid.createModel('foo', props);
+ var MyModel = loopback.createModel('foo', props);
console.log(MyModel.properties);
@@ -191,8 +191,8 @@ Outputs:
Attach a model to a [DataSource](#data-source). Attaching a [DataSource](#data-source) updates the model with additional methods and behaviors.
- var oracle = asteroid.createDataSource({
- connector: require('asteroid-connector-oracle'),
+ var oracle = loopback.createDataSource({
+ connector: require('loopback-connector-oracle'),
host: '111.22.333.44',
database: 'MYDB',
username: 'username',
@@ -296,7 +296,7 @@ Define a static model method.
Setup the static model method to be exposed to clients as a [remote method](#remote-method).
- asteroid.remoteMethod(
+ loopback.remoteMethod(
User.login,
{
accepts: [
@@ -350,13 +350,13 @@ Define an instance method.
Define a remote model instance method.
- asteroid.remoteMethod(User.prototype.logout);
+ loopback.remoteMethod(User.prototype.logout);
#### Remote Methods
Both instance and static methods can be exposed to clients. A remote method must accept a callback with the conventional `fn(err, result, ...)` signature.
-##### asteroid.remoteMethod(fn, [options]);
+##### loopback.remoteMethod(fn, [options]);
Expose a remote method.
@@ -364,7 +364,7 @@ Expose a remote method.
myApi.getStats('products', fn);
}
- asteroid.remoteMethod(
+ loopback.remoteMethod(
Product.stats,
{
returns: {arg: 'stats', type: 'array'},
@@ -394,7 +394,7 @@ An arguments description defines either a single argument as an object or an ord
**Types**
-Each argument may define any of the [asteroid types](#asteroid-types).
+Each argument may define any of the [loopback types](#loopback-types).
**Notes:**
@@ -464,7 +464,7 @@ During `afterRemote` hooks, `ctx.result` will contain the data about to be sent
##### Rest
-When [asteroid.rest](#asteroidrest) is used the following `ctx` properties are available.
+When [loopback.rest](#loopbackrest) is used the following `ctx` properties are available.
###### ctx.req
@@ -522,15 +522,15 @@ TODO: implement / document
#### Shared Methods
-Any static or instance method can be decorated as `shared`. These methods are exposed over the provided transport (eg. [asteroid.rest](#rest)).
+Any static or instance method can be decorated as `shared`. These methods are exposed over the provided transport (eg. [loopback.rest](#rest)).
### Data Source
-An Asteroid `DataSource` provides [Models](#model) with the ability to manipulate data. Attaching a `DataSource` to a `Model` adds [instance methods](#instance-methods) and [static methods](#static-methods) to the `Model`. The added methods may be [remote methods](#remote-methods).
+An Loopback `DataSource` provides [Models](#model) with the ability to manipulate data. Attaching a `DataSource` to a `Model` adds [instance methods](#instance-methods) and [static methods](#static-methods) to the `Model`. The added methods may be [remote methods](#remote-methods).
Define a data source for persisting models.
- var oracle = asteroid.createDataSource({
+ var oracle = loopback.createDataSource({
connector: 'oracle',
host: '111.22.333.44',
database: 'MYDB',
@@ -665,8 +665,8 @@ Disable remote access to a data source operation. Each [connector](#connector) h
// all rest data source operations are
// disabled by default
- var oracle = asteroid.createDataSource({
- connector: require('asteroid-connector-oracle'),
+ var oracle = loopback.createDataSource({
+ connector: require('loopback-connector-oracle'),
host: '...',
...
});
@@ -709,22 +709,22 @@ Output:
Create a data source with a specific connector. See **available connectors** for specific connector documentation.
- var memory = asteroid.createDataSource({
- connector: asteroid.Memory
+ var memory = loopback.createDataSource({
+ connector: loopback.Memory
});
**Available Connectors**
- - [Oracle](http://github.com/strongloop/asteroid-connectors/oracle)
- - [In Memory](http://github.com/strongloop/asteroid-connectors/memory)
- - TODO - [REST](http://github.com/strongloop/asteroid-connectors/rest)
- - TODO - [MySQL](http://github.com/strongloop/asteroid-connectors/mysql)
- - TODO - [SQLite3](http://github.com/strongloop/asteroid-connectors/sqlite)
- - TODO - [Postgres](http://github.com/strongloop/asteroid-connectors/postgres)
- - TODO - [Redis](http://github.com/strongloop/asteroid-connectors/redis)
- - TODO - [MongoDB](http://github.com/strongloop/asteroid-connectors/mongo)
- - TODO - [CouchDB](http://github.com/strongloop/asteroid-connectors/couch)
- - TODO - [Firebird](http://github.com/strongloop/asteroid-connectors/firebird)
+ - [Oracle](http://github.com/strongloop/loopback-connectors/oracle)
+ - [In Memory](http://github.com/strongloop/loopback-connectors/memory)
+ - TODO - [REST](http://github.com/strongloop/loopback-connectors/rest)
+ - TODO - [MySQL](http://github.com/strongloop/loopback-connectors/mysql)
+ - TODO - [SQLite3](http://github.com/strongloop/loopback-connectors/sqlite)
+ - TODO - [Postgres](http://github.com/strongloop/loopback-connectors/postgres)
+ - TODO - [Redis](http://github.com/strongloop/loopback-connectors/redis)
+ - TODO - [MongoDB](http://github.com/strongloop/loopback-connectors/mongo)
+ - TODO - [CouchDB](http://github.com/strongloop/loopback-connectors/couch)
+ - TODO - [Firebird](http://github.com/strongloop/loopback-connectors/firebird)
**Installing Connectors**
@@ -732,7 +732,7 @@ Include the connector in your package.json dependencies and run `npm install`.
{
"dependencies": {
- "asteroid-connector-oracle": "latest"
+ "loopback-connector-oracle": "latest"
}
}
@@ -740,15 +740,15 @@ Include the connector in your package.json dependencies and run `npm install`.
Use the `GeoPoint` class.
- var GeoPoint = require('asteroid').GeoPoint;
+ var GeoPoint = require('loopback').GeoPoint;
Embed a latitude / longitude point in a [Model](#model).
- var CoffeeShop = asteroid.createModel('coffee-shop', {
+ var CoffeeShop = loopback.createModel('coffee-shop', {
location: 'GeoPoint'
});
-Asteroid Model's with a GeoPoint property and an attached DataSource may be queried using geo spatial filters and sorting.
+Loopback Model's with a GeoPoint property and an attached DataSource may be queried using geo spatial filters and sorting.
Find the 3 nearest coffee shops.
@@ -792,9 +792,9 @@ The latitude point in degrees. Range: -90 to 90.
The longitude point in degrees. Range: -180 to 180.
-### Asteroid Types
+### Loopback Types
-Various APIs in Asteroid accept type descriptions (eg. [remote methods](#remote-methods), [asteroid.createModel()](#model)). The following is a list of supported types.
+Various APIs in Loopback accept type descriptions (eg. [remote methods](#remote-methods), [loopback.createModel()](#model)). The following is a list of supported types.
- `null` - JSON null
- `Boolean` - JSON boolean
@@ -804,18 +804,18 @@ Various APIs in Asteroid accept type descriptions (eg. [remote methods](#remote-
- `Array` - JSON array
- `Date` - a JavaScript date object
- `Buffer` - a node.js Buffer object
- - [GeoPoint](#geopoint) - an asteroid GeoPoint object. TODO
+ - [GeoPoint](#geopoint) - an loopback GeoPoint object. TODO
## Bundled Models
-The Asteroid library is unopinioned in the way you define your app's data and logic. Asteroid also bundles useful pre-built models for common use cases.
+The Loopback library is unopinioned in the way you define your app's data and logic. Loopback also bundles useful pre-built models for common use cases.
- User - register and authenticate users of your app locally or against 3rd party services.
- Notification - _TODO_ create, store, schedule and send push notifications to your app users.
- Email - send emails to your app users using smtp or 3rd party services.
- Job - _TODO_ schedule arbitrary code to run at a given time.
-Defining a model with `asteroid.createModel()` is really just extending the base `asteroid.Model` type using `asteroid.Model.extend()`. The bundled models extend from the base `asteroid.Model` allowing you to extend them arbitrarily.
+Defining a model with `loopback.createModel()` is really just extending the base `loopback.Model` type using `loopback.Model.extend()`. The bundled models extend from the base `loopback.Model` allowing you to extend them arbitrarily.
### User Model
@@ -823,13 +823,13 @@ Register and authenticate users of your app locally or against 3rd party service
#### Create a User Model
-Extend a vanilla Asteroid model using the built in User model.
+Extend a vanilla Loopback model using the built in User model.
// create a data source
- var memory = asteroid.memory();
+ var memory = loopback.memory();
// define a User model
- var User = asteroid.User.extend('user');
+ var User = loopback.User.extend('user');
// attach to the memory connector
User.attachTo(memory);
@@ -840,15 +840,15 @@ Extend a vanilla Asteroid model using the built in User model.
// expose over the app's api
app.model(User);
-**Note:** By default the `asteroid.User` model uses the `asteroid.Session` model to persist sessions. You can change this by setting the `session` property.
+**Note:** By default the `loopback.User` model uses the `loopback.Session` model to persist sessions. You can change this by setting the `session` property.
**Note:** You must attach both the `User` and `User.session` model's to a data source!
// define a custom session model
- var MySession = asteroid.Session.extend('my-session');
+ var MySession = loopback.Session.extend('my-session');
// define a custom User model
- var User = asteroid.User.extend('user');
+ var User = loopback.User.extend('user');
// use the custom session model
User.session = MySession;
@@ -978,7 +978,7 @@ Send an email to the user's supplied email address containing a link to reset th
#### Remote Password Reset
-The password reset email will send users to a page rendered by asteroid with fields required to reset the user's password. You may customize this template by defining a `resetTemplate` setting.
+The password reset email will send users to a page rendered by loopback with fields required to reset the user's password. You may customize this template by defining a `resetTemplate` setting.
User.settings.resetTemplate = 'reset.ejs';
@@ -993,30 +993,30 @@ Confirm the password reset.
### Session Model
-Identify users by creating sessions when they connect to your asteroid app. By default the `asteroid.User` model uses the `asteroid.Session` model to persist sessions. You can change this by setting the `session` property.
+Identify users by creating sessions when they connect to your loopback app. By default the `loopback.User` model uses the `loopback.Session` model to persist sessions. You can change this by setting the `session` property.
// define a custom session model
- var MySession = asteroid.Session.extend('my-session');
+ var MySession = loopback.Session.extend('my-session');
// define a custom User model
- var User = asteroid.User.extend('user');
+ var User = loopback.User.extend('user');
// use the custom session model
User.session = MySession;
// attach both Session and User to a data source
- User.attachTo(asteroid.memory());
- MySession.attachTo(asteroid.memory());
+ User.attachTo(loopback.memory());
+ MySession.attachTo(loopback.memory());
### Email Model
-Send emails from your asteroid app.
+Send emails from your loopback app.
### REST Router
-Expose models over rest using the `asteroid.rest` router.
+Expose models over rest using the `loopback.rest` router.
- app.use(asteroid.rest());
+ app.use(loopback.rest());
**REST Documentation**
@@ -1024,7 +1024,7 @@ View generated REST documentation by visiting: [http://localhost:3000/_docs](htt
### SocketIO Middleware **Not Available**
-**Coming Soon** - Expose models over socket.io using the `asteroid.sio()` middleware.
+**Coming Soon** - Expose models over socket.io using the `loopback.sio()` middleware.
- app.use(asteroid.sio);
+ app.use(loopback.sio);
diff --git a/example/colors/app.js b/example/colors/app.js
index 5572b2e2..a7fdb01f 100644
--- a/example/colors/app.js
+++ b/example/colors/app.js
@@ -1,7 +1,7 @@
-var asteroid = require('../../');
-var app = asteroid();
+var loopback = require('../../');
+var app = loopback();
-app.use(asteroid.rest());
+app.use(loopback.rest());
var schema = {
name: String
diff --git a/example/simple-data-source/app.js b/example/simple-data-source/app.js
index 9b4f0569..08d6d94a 100644
--- a/example/simple-data-source/app.js
+++ b/example/simple-data-source/app.js
@@ -1,7 +1,7 @@
-var asteroid = require('../../');
-var app = asteroid();
+var loopback = require('../../');
+var app = loopback();
-app.use(asteroid.rest());
+app.use(loopback.rest());
var dataSource = app.dataSource('db', {adapter: 'memory'});
diff --git a/example/todos/app.js b/example/todos/app.js
index f5411dc5..8a2dd304 100644
--- a/example/todos/app.js
+++ b/example/todos/app.js
@@ -1,8 +1,8 @@
-var asteroid = require('../../');
-var app = asteroid();
+var loopback = require('../../');
+var app = loopback();
-app.use(asteroid.configure());
-app.use(asteroid.bodyParser());
-app.use(asteroid.routes());
+app.use(loopback.configure());
+app.use(loopback.bodyParser());
+app.use(loopback.routes());
app.listen(3000);
\ No newline at end of file
diff --git a/index.js b/index.js
index 39bdd874..e5802780 100644
--- a/index.js
+++ b/index.js
@@ -1,18 +1,18 @@
/**
- * asteroid ~ public api
+ * loopback ~ public api
*/
-var asteroid = module.exports = require('./lib/asteroid');
+var loopback = module.exports = require('./lib/loopback');
/**
* Connectors
*/
-asteroid.Connector = require('./lib/connectors/base-connector');
-asteroid.Memory = require('./lib/connectors/memory');
+loopback.Connector = require('./lib/connectors/base-connector');
+loopback.Memory = require('./lib/connectors/memory');
/**
* Types
*/
-asteroid.GeoPoint = require('jugglingdb/lib/geo').GeoPoint;
\ No newline at end of file
+loopback.GeoPoint = require('jugglingdb/lib/geo').GeoPoint;
\ No newline at end of file
diff --git a/lib/asteroid.js b/lib/asteroid.js
deleted file mode 100644
index 094e1d70..00000000
--- a/lib/asteroid.js
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- * Module dependencies.
- */
-
-var express = require('express')
- , fs = require('fs')
- , ejs = require('ejs')
- , EventEmitter = require('events').EventEmitter
- , path = require('path')
- , proto = require('./application')
- , utils = require('express/node_modules/connect').utils
- , DataSource = require('jugglingdb').DataSource
- , ModelBuilder = require('jugglingdb').ModelBuilder
- , assert = require('assert')
- , i8n = require('inflection');
-
-/**
- * Expose `createApplication()`.
- */
-
-var asteroid = exports = module.exports = createApplication;
-
-/**
- * Framework version.
- */
-
-asteroid.version = require('../package.json').version;
-
-/**
- * Expose mime.
- */
-
-asteroid.mime = express.mime;
-
-/**
- * Create an asteroid application.
- *
- * @return {Function}
- * @api public
- */
-
-function createApplication() {
- var app = express();
-
- utils.merge(app, proto);
-
- return app;
-}
-
-/**
- * Expose express.middleware as asteroid.*
- * for example `asteroid.errorHandler` etc.
- */
-
-for (var key in express) {
- Object.defineProperty(
- asteroid
- , key
- , Object.getOwnPropertyDescriptor(express, key));
-}
-
-/**
- * Expose additional asteroid middleware
- * for example `asteroid.configure` etc.
- */
-
-fs
- .readdirSync(path.join(__dirname, 'middleware'))
- .filter(function (file) {
- return file.match(/\.js$/);
- })
- .forEach(function (m) {
- asteroid[m.replace(/\.js$/, '')] = require('./middleware/' + m);
- });
-
-/**
- * Error handler title
- */
-
-asteroid.errorHandler.title = 'Asteroid';
-
-/**
- * Create a data source with passing the provided options to the connector.
- *
- * @param {String} name (optional)
- * @param {Object} options
- *
- * - connector - an asteroid connector
- * - other values - see the specified `connector` docs
- */
-
-asteroid.createDataSource = function (name, options) {
- var ds = new DataSource(name, options);
- ds.createModel = function (name, properties, settings) {
- var ModelCtor = asteroid.createModel(name, properties, settings);
- ModelCtor.attachTo(ds);
-
- var hasMany = ModelCtor.hasMany;
-
- if(hasMany) {
- ModelCtor.hasMany = function (anotherClass, params) {
- var origArgs = arguments;
- var thisClass = this, thisClassName = this.modelName;
- params = params || {};
- if (typeof anotherClass === 'string') {
- params.as = anotherClass;
- if (params.model) {
- anotherClass = params.model;
- } else {
- var anotherClassName = i8n.singularize(anotherClass).toLowerCase();
- for(var name in this.schema.models) {
- if (name.toLowerCase() === anotherClassName) {
- anotherClass = this.schema.models[name];
- }
- }
- }
- }
-
- var pluralized = i8n.pluralize(anotherClass.modelName);
- var methodName = params.as ||
- i8n.camelize(pluralized, true);
- var proxyMethodName = 'get' + i8n.titleize(pluralized, true);
-
- // create a proxy method
- var fn = this.prototype[proxyMethodName] = function () {
- // this[methodName] cannot be a shared method
- // because it is defined inside
- // a property getter...
-
- this[methodName].apply(thisClass, arguments);
- };
-
- fn.shared = true;
- fn.http = {verb: 'get', path: '/' + methodName};
- fn.accepts = {arg: 'where', type: 'object'};
- hasMany.apply(this, arguments);
- };
- }
-
- return ModelCtor;
- }
- return ds;
-}
-
-/**
- * Create a named vanilla JavaScript class constructor with an attached set of properties and options.
- *
- * @param {String} name - must be unique
- * @param {Object} properties
- * @param {Object} options (optional)
- */
-
-asteroid.createModel = function (name, properties, options) {
- return asteroid.Model.extend(name, properties, options);
-}
-
-/**
- * Add a remote method to a model.
- * @param {Function} fn
- * @param {Object} options (optional)
- */
-
-asteroid.remoteMethod = function (fn, options) {
- fn.shared = true;
- if(typeof options === 'object') {
- Object.keys(options).forEach(function (key) {
- fn[key] = options[key];
- });
- }
- fn.http = fn.http || {verb: 'get'};
-}
-
-/**
- * Create a template helper.
- *
- * var render = asteroid.template('foo.ejs');
- * var html = render({foo: 'bar'});
- *
- * @param {String} path Path to the template file.
- * @returns {Function}
- */
-
-asteroid.template = function (file) {
- var templates = this._templates || (this._templates = {});
- var str = templates[file] || (templates[file] = fs.readFileSync(file, 'utf8'));
- return ejs.compile(str);
-}
-
-/**
- * Get an in-memory data source. Use one if it already exists.
- *
- * @param {String} [name] The name of the data source. If not provided, the `'default'` is used.
- */
-
-asteroid.memory = function (name) {
- name = name || 'default';
- var memory = (
- this._memoryDataSources
- || (this._memoryDataSources = {})
- )[name];
-
- if(!memory) {
- memory = this._memoryDataSources[name] = asteroid.createDataSource({
- connector: asteroid.Memory
- });
- }
-
- return memory;
-}
-
-/*
- * Built in models / services
- */
-
-asteroid.Model = require('./models/model');
-asteroid.Email = require('./models/email');
-asteroid.User = require('./models/user');
-asteroid.Session = require('./models/session');
diff --git a/lib/middleware/auth.js b/lib/middleware/auth.js
index 79f8acd9..c278aa8c 100644
--- a/lib/middleware/auth.js
+++ b/lib/middleware/auth.js
@@ -2,7 +2,7 @@
* Module dependencies.
*/
-var asteroid = require('../asteroid')
+var loopback = require('../loopback')
, passport = require('passport');
/**
@@ -17,13 +17,13 @@ module.exports = auth;
function auth() {
return function (req, res, next) {
- var sub = asteroid();
+ var sub = loopback();
// TODO clean this up
sub._models = req.app._models;
sub._remotes = req.app._remotes;
- sub.use(asteroid.session({secret: 'change me'}))
+ sub.use(loopback.session({secret: 'change me'}))
sub.use(passport.initialize());
sub.use(passport.session());
diff --git a/lib/middleware/rest.js b/lib/middleware/rest.js
index a22dadcf..468d0a44 100644
--- a/lib/middleware/rest.js
+++ b/lib/middleware/rest.js
@@ -2,7 +2,7 @@
* Module dependencies.
*/
-var asteroid = require('../asteroid');
+var loopback = require('../loopback');
var RemoteObjects = require('sl-remoting');
/**
diff --git a/lib/models/email.js b/lib/models/email.js
index bcc9cb39..e9358b2b 100644
--- a/lib/models/email.js
+++ b/lib/models/email.js
@@ -2,8 +2,8 @@
* Module Dependencies.
*/
-var Model = require('../asteroid').Model
- , asteroid = require('../asteroid')
+var Model = require('../loopback').Model
+ , loopback = require('../loopback')
, mailer = require("nodemailer");
/**
@@ -19,7 +19,7 @@ var properties = {
};
/**
- * Extends from the built in `asteroid.Model` type.
+ * Extends from the built in `loopback.Model` type.
*/
var Email = module.exports = Model.extend('email', properties);
diff --git a/lib/models/model.js b/lib/models/model.js
index cee50fa3..32e51364 100644
--- a/lib/models/model.js
+++ b/lib/models/model.js
@@ -6,7 +6,7 @@ var ModelBuilder = require('jugglingdb').ModelBuilder;
var modeler = new ModelBuilder();
/**
- * Define the built in asteroid.Model.
+ * Define the built in loopback.Model.
*/
var Model = module.exports = modeler.define('model');
diff --git a/lib/models/session.js b/lib/models/session.js
index 6ce1ed96..7bf76250 100644
--- a/lib/models/session.js
+++ b/lib/models/session.js
@@ -2,8 +2,8 @@
* Module Dependencies.
*/
-var Model = require('../asteroid').Model
- , asteroid = require('../asteroid')
+var Model = require('../loopback').Model
+ , loopback = require('../loopback')
, crypto = require('crypto');
/**
@@ -17,7 +17,7 @@ var properties = {
};
/**
- * Extends from the built in `asteroid.Model` type.
+ * Extends from the built in `loopback.Model` type.
*/
var Session = module.exports = Model.extend('session', properties);
diff --git a/lib/models/user.js b/lib/models/user.js
index f99f127f..2865668d 100644
--- a/lib/models/user.js
+++ b/lib/models/user.js
@@ -2,8 +2,8 @@
* Module Dependencies.
*/
-var Model = require('../asteroid').Model
- , asteroid = require('../asteroid')
+var Model = require('../loopback').Model
+ , loopback = require('../loopback')
, path = require('path')
, SALT_WORK_FACTOR = 10
, crypto = require('crypto')
@@ -41,7 +41,7 @@ var properties = {
/**
- * Extends from the built in `asteroid.Model` type.
+ * Extends from the built in `loopback.Model` type.
*/
var User = module.exports = Model.extend('user', properties);
@@ -114,7 +114,7 @@ User.login = function (credentials, fn) {
User.logout = function (sid, fn) {
var UserCtor = this;
- var Session = UserCtor.settings.session || asteroid.Session;
+ var Session = UserCtor.settings.session || loopback.Session;
Session.findById(sid, function (err, session) {
if(err) {
@@ -183,7 +183,7 @@ User.prototype.verify = function (options, fn) {
// Email model
- var Email = options.mailer || this.constructor.email || asteroid.Email;
+ var Email = options.mailer || this.constructor.email || loopback.Email;
crypto.randomBytes(64, function(err, buf) {
if(err) {
@@ -208,7 +208,7 @@ User.prototype.verify = function (options, fn) {
options.text = options.text.replace('{href}', options.verifyHref);
- var template = asteroid.template(options.template);
+ var template = loopback.template(options.template);
Email.send({
to: options.to || user.email,
subject: options.subject || 'Thanks for Registering',
@@ -257,7 +257,7 @@ User.setup = function () {
this._password = bcrypt.hashSync(plain, salt);
}
- asteroid.remoteMethod(
+ loopback.remoteMethod(
UserModel.login,
{
accepts: [
@@ -268,7 +268,7 @@ User.setup = function () {
}
);
- asteroid.remoteMethod(
+ loopback.remoteMethod(
UserModel.logout,
{
accepts: [
@@ -278,7 +278,7 @@ User.setup = function () {
}
);
- asteroid.remoteMethod(
+ loopback.remoteMethod(
UserModel.confirm,
{
accepts: [
diff --git a/package.json b/package.json
index 5f83d169..0e5e3e01 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
- "name": "asteroid",
- "description": "asteroid",
+ "name": "loopback",
+ "description": "loopback",
"version": "0.9.0",
"scripts": {
"test": "mocha -R spec"
diff --git a/test/README.md b/test/README.md
index 44d20f69..ea5f0300 100644
--- a/test/README.md
+++ b/test/README.md
@@ -2,10 +2,10 @@
- [app](#app)
- [app.model(Model)](#app-appmodelmodel)
- [app.models()](#app-appmodels)
- - [asteroid](#asteroid)
- - [asteroid.createDataSource(options)](#asteroid-asteroidcreatedatasourceoptions)
- - [asteroid.remoteMethod(Model, fn, [options]);](#asteroid-asteroidremotemethodmodel-fn-options)
- - [asteroid.memory([name])](#asteroid-asteroidmemoryname)
+ - [loopback](#loopback)
+ - [loopback.createDataSource(options)](#loopback-loopbackcreatedatasourceoptions)
+ - [loopback.remoteMethod(Model, fn, [options]);](#loopback-loopbackremotemethodmodel-fn-options)
+ - [loopback.memory([name])](#loopback-loopbackmemoryname)
- [DataSource](#datasource)
- [dataSource.createModel(name, properties, settings)](#datasource-datasourcecreatemodelname-properties-settings)
- [dataSource.operations()](#datasource-datasourceoperations)
@@ -56,7 +56,7 @@
Expose a `Model` to remote clients..
```js
-var memory = asteroid.createDataSource({connector: asteroid.Memory});
+var memory = loopback.createDataSource({connector: loopback.Memory});
var Color = memory.createModel('color', {name: String});
app.model(Color);
assert.equal(app.models().length, 1);
@@ -67,38 +67,38 @@ assert.equal(app.models().length, 1);
Get the app's exposed models..
```js
-var Color = asteroid.createModel('color', {name: String});
+var Color = loopback.createModel('color', {name: String});
var models = app.models();
assert.equal(models.length, 1);
assert.equal(models[0].modelName, 'color');
```
-
-# asteroid
-
-## asteroid.createDataSource(options)
+
+# loopback
+
+## loopback.createDataSource(options)
Create a data source with a connector..
```js
-var dataSource = asteroid.createDataSource({
- connector: asteroid.Memory
+var dataSource = loopback.createDataSource({
+ connector: loopback.Memory
});
assert(dataSource.connector());
```
-
-## asteroid.remoteMethod(Model, fn, [options]);
+
+## loopback.remoteMethod(Model, fn, [options]);
Setup a remote method..
```js
-var Product = asteroid.createModel('product', {price: Number});
+var Product = loopback.createModel('product', {price: Number});
Product.stats = function(fn) {
// ...
}
-asteroid.remoteMethod(
+loopback.remoteMethod(
Product.stats,
{
returns: {arg: 'stats', type: 'array'},
@@ -113,16 +113,16 @@ assert.equal(Product.stats.http.verb, 'get');
assert.equal(Product.stats.shared, true);
```
-
-## asteroid.memory([name])
+
+## loopback.memory([name])
Get an in-memory data source. Use one if it already exists..
```js
-var memory = asteroid.memory();
+var memory = loopback.memory();
assertValidDataSource(memory);
-var m1 = asteroid.memory();
-var m2 = asteroid.memory('m2');
-var alsoM2 = asteroid.memory('m2');
+var m1 = loopback.memory();
+var m2 = loopback.memory('m2');
+var alsoM2 = loopback.memory('m2');
assert(m1 === memory);
assert(m1 !== m2);
@@ -257,7 +257,7 @@ assert.equal(point.lat, 6.777);
Create as Model property.
```js
-var Model = asteroid.createModel('geo-model', {
+var Model = loopback.createModel('geo-model', {
geo: {type: 'GeoPoint'}
});
@@ -385,7 +385,7 @@ user.isValid(function (valid) {
Attach a model to a [DataSource](#data-source).
```js
-var MyModel = asteroid.createModel('my-model', {name: String});
+var MyModel = loopback.createModel('my-model', {name: String});
assert(MyModel.find === undefined, 'should not have data access methods');
@@ -706,7 +706,7 @@ Book.create({title: 'Into the Wild', author: 'Jon Krakauer'}, function(err, book
## Model.properties
-Normalized properties passed in originally by asteroid.createModel()..
+Normalized properties passed in originally by loopback.createModel()..
```js
var props = {
@@ -714,10 +714,10 @@ var props = {
n: {type: 'Number'},
o: {type: 'String', min: 10, max: 100},
d: Date,
- g: asteroid.GeoPoint
+ g: loopback.GeoPoint
};
-var MyModel = asteroid.createModel('foo', props);
+var MyModel = loopback.createModel('foo', props);
Object.keys(MyModel.properties).forEach(function (key) {
var p = MyModel.properties[key];
@@ -743,7 +743,7 @@ Object.keys(MyModel.properties).forEach(function (key) {
Create a new model by extending an existing model..
```js
-var User = asteroid.Model.extend('test-user', {
+var User = loopback.Model.extend('test-user', {
email: String
});
diff --git a/test/app.test.js b/test/app.test.js
index 72387eb9..a27748c4 100644
--- a/test/app.test.js
+++ b/test/app.test.js
@@ -2,7 +2,7 @@ describe('app', function() {
describe('app.model(Model)', function() {
it("Expose a `Model` to remote clients.", function() {
- var memory = asteroid.createDataSource({connector: asteroid.Memory});
+ var memory = loopback.createDataSource({connector: loopback.Memory});
var Color = memory.createModel('color', {name: String});
app.model(Color);
assert.equal(app.models().length, 1);
@@ -11,7 +11,7 @@ describe('app', function() {
describe('app.models()', function() {
it("Get the app's exposed models.", function() {
- var Color = asteroid.createModel('color', {name: String});
+ var Color = loopback.createModel('color', {name: String});
var models = app.models();
assert.equal(models.length, 1);
diff --git a/test/asteroid.test.js b/test/asteroid.test.js
deleted file mode 100644
index 3b596931..00000000
--- a/test/asteroid.test.js
+++ /dev/null
@@ -1,48 +0,0 @@
-describe('asteroid', function() {
- describe('asteroid.createDataSource(options)', function(){
- it('Create a data source with a connector.', function() {
- var dataSource = asteroid.createDataSource({
- connector: asteroid.Memory
- });
- assert(dataSource.connector());
- });
- });
-
- describe('asteroid.remoteMethod(Model, fn, [options]);', function() {
- it("Setup a remote method.", function() {
- var Product = asteroid.createModel('product', {price: Number});
-
- Product.stats = function(fn) {
- // ...
- }
-
- asteroid.remoteMethod(
- Product.stats,
- {
- returns: {arg: 'stats', type: 'array'},
- http: {path: '/info', verb: 'get'}
- }
- );
-
- assert.equal(Product.stats.returns.arg, 'stats');
- assert.equal(Product.stats.returns.type, 'array');
- assert.equal(Product.stats.http.path, '/info');
- assert.equal(Product.stats.http.verb, 'get');
- assert.equal(Product.stats.shared, true);
- });
- });
-
- describe('asteroid.memory([name])', function(){
- it('Get an in-memory data source. Use one if it already exists.', function() {
- var memory = asteroid.memory();
- assertValidDataSource(memory);
- var m1 = asteroid.memory();
- var m2 = asteroid.memory('m2');
- var alsoM2 = asteroid.memory('m2');
-
- assert(m1 === memory);
- assert(m1 !== m2);
- assert(alsoM2 === m2);
- });
- });
-});
\ No newline at end of file
diff --git a/test/data-source.test.js b/test/data-source.test.js
index 832a9d44..155f8888 100644
--- a/test/data-source.test.js
+++ b/test/data-source.test.js
@@ -2,8 +2,8 @@ describe('DataSource', function() {
var memory;
beforeEach(function(){
- memory = asteroid.createDataSource({
- connector: asteroid.Memory
+ memory = loopback.createDataSource({
+ connector: loopback.Memory
});
assertValidDataSource(memory);
diff --git a/test/geo-point.test.js b/test/geo-point.test.js
index e794835e..223df816 100644
--- a/test/geo-point.test.js
+++ b/test/geo-point.test.js
@@ -40,7 +40,7 @@ describe('GeoPoint', function() {
assert.equal(point.lat, 6.777);
});
it('Create as Model property', function() {
- var Model = asteroid.createModel('geo-model', {
+ var Model = loopback.createModel('geo-model', {
geo: {type: 'GeoPoint'}
});
diff --git a/test/model.test.js b/test/model.test.js
index 2b08634f..9e43c51f 100644
--- a/test/model.test.js
+++ b/test/model.test.js
@@ -3,7 +3,7 @@ describe('Model', function() {
var User, memory;
beforeEach(function () {
- memory = asteroid.createDataSource({connector: asteroid.Memory});
+ memory = loopback.createDataSource({connector: loopback.Memory});
User = memory.createModel('user', {
'first': String,
'last': String,
@@ -109,7 +109,7 @@ describe('Model', function() {
describe('Model.attachTo(dataSource)', function() {
it("Attach a model to a [DataSource](#data-source)", function() {
- var MyModel = asteroid.createModel('my-model', {name: String});
+ var MyModel = loopback.createModel('my-model', {name: String});
assert(MyModel.find === undefined, 'should not have data access methods');
@@ -254,7 +254,7 @@ describe('Model', function() {
}
}
- asteroid.remoteMethod(
+ loopback.remoteMethod(
User.login,
{
accepts: [
@@ -266,7 +266,7 @@ describe('Model', function() {
}
);
- app.use(asteroid.rest());
+ app.use(loopback.rest());
app.model(User);
});
@@ -433,16 +433,16 @@ describe('Model', function() {
});
describe('Model.properties', function(){
- it('Normalized properties passed in originally by asteroid.createModel().', function() {
+ it('Normalized properties passed in originally by loopback.createModel().', function() {
var props = {
s: String,
n: {type: 'Number'},
o: {type: 'String', min: 10, max: 100},
d: Date,
- g: asteroid.GeoPoint
+ g: loopback.GeoPoint
};
- var MyModel = asteroid.createModel('foo', props);
+ var MyModel = loopback.createModel('foo', props);
Object.keys(MyModel.properties).forEach(function (key) {
var p = MyModel.properties[key];
@@ -466,7 +466,7 @@ describe('Model', function() {
describe('Model.extend()', function(){
it('Create a new model by extending an existing model.', function() {
- var User = asteroid.Model.extend('test-user', {
+ var User = loopback.Model.extend('test-user', {
email: String
});
@@ -531,7 +531,7 @@ describe('Model', function() {
// },
// ...
// }
- // var oracle = asteroid.createDataSource({
+ // var oracle = loopback.createDataSource({
// connector: 'oracle',
// host: '111.22.333.44',
// database: 'MYDB',
diff --git a/test/support.js b/test/support.js
index 24014c52..1983d420 100644
--- a/test/support.js
+++ b/test/support.js
@@ -1,17 +1,17 @@
/**
- * asteroid test setup and support.
+ * loopback test setup and support.
*/
assert = require('assert');
-asteroid = require('../');
-memoryConnector = asteroid.Memory;
-GeoPoint = asteroid.GeoPoint;
+loopback = require('../');
+memoryConnector = loopback.Memory;
+GeoPoint = loopback.GeoPoint;
app = null;
TaskEmitter = require('sl-task-emitter');
request = require('supertest');
beforeEach(function () {
- app = asteroid();
+ app = loopback();
});
assertValidDataSource = function (dataSource) {
diff --git a/test/user.test.js b/test/user.test.js
index 73efdcf6..9ef24b42 100644
--- a/test/user.test.js
+++ b/test/user.test.js
@@ -1,9 +1,9 @@
-var User = asteroid.User.extend('user');
-var Session = asteroid.Session;
+var User = loopback.User.extend('user');
+var Session = loopback.Session;
var passport = require('passport');
-var userMemory = asteroid.createDataSource({
- connector: asteroid.Memory
+var userMemory = loopback.createDataSource({
+ connector: loopback.Memory
});
@@ -17,9 +17,9 @@ describe('User', function(){
User.setMaxListeners(22);
beforeEach(function (done) {
- app.use(asteroid.cookieParser());
- app.use(asteroid.auth());
- app.use(asteroid.rest());
+ app.use(loopback.cookieParser());
+ app.use(loopback.auth());
+ app.use(loopback.rest());
app.model(User);
User.create({email: 'foo@bar.com', password: 'bar'}, done);