Skip to content

Commit

Permalink
Update loopback packages to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Jan 30, 2016
1 parent 37aed6e commit 729057c
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 109 deletions.
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

save-exact=true
3 changes: 3 additions & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"generator-loopback": {}
}
12 changes: 1 addition & 11 deletions common/models/app-model.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
module.exports = function(AppModel) {

AppModel.beforeCreate = function(next, instance) {
instance.created = instance.modified = Date.now();
next();
};

AppModel.beforeUpdate = function(next, instance) {
instance.modified = Date.now();
next();
};
module.exports = function (AppModel) {

};
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
},
"main": "server/server.js",
"dependencies": {
"async": "0.9.0",
"async": "^0.9.0",
"bluebird": "^2.10.0",
"body-parser": "1.11.0",
"bower": "1.3.12",
"compression": "1.4.0",
"compression": "^1.0.3",
"connect-ensure-login": "0.1.1",
"cookie-parser": "1.3.3",
"debug": "2.1.3",
"errorhandler": "1.3.3",
"errorhandler": "^1.1.1",
"eventemitter3": "0.1.6",
"express-session": "1.10.2",
"faker": "3.0.1",
Expand Down Expand Up @@ -71,12 +71,13 @@
"jshint-stylish": "1.0.0",
"load-grunt-tasks": "3.1.0",
"lodash": "3.10.1",
"loopback": "2.19.0",
"loopback-boot": "2.6.4",
"loopback-component-passport": "1.1.2",
"loopback-component-storage": "1.2.0",
"loopback-connector-mongodb": "1.11.3",
"loopback-datasource-juggler": "2.33.1",
"loopback": "^2.22.0",
"loopback-boot": "2.16.0",
"loopback-component-explorer": "2.2.0",
"loopback-component-passport": "2.0.0",
"loopback-component-storage": "1.6.1",
"loopback-connector-mongodb": "1.13.3",
"loopback-datasource-juggler": "2.44.0",
"nodemon": "1.3.7",
"passport": "0.2.1",
"passport-facebook": "1.0.3",
Expand All @@ -85,12 +86,10 @@
"passport-oauth2": "1.1.2",
"passport-twitter": "1.0.2",
"serve-favicon": "2.2.0",
"serve-static": "^1.10.0",
"showdown": "0.3.1",
"time-grunt": "1.0.0"
},
"optionalDependencies": {
"loopback-explorer": "1.6.4"
},
"devDependencies": {
"browserify": "8.1.3",
"connect-livereload": "0.5.2",
Expand Down
2 changes: 0 additions & 2 deletions server/boot/authentication.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = function enableAuthentication(server) {
// enable authentication
server.enableAuth();
Expand Down
27 changes: 0 additions & 27 deletions server/boot/explorer.js

This file was deleted.

6 changes: 0 additions & 6 deletions server/boot/rest-api.js

This file was deleted.

2 changes: 0 additions & 2 deletions server/boot/root.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = function(server) {
// Install a `/` route that returns server status
var router = server.loopback.Router();
Expand Down
5 changes: 5 additions & 0 deletions server/component-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}
21 changes: 21 additions & 0 deletions server/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,26 @@
"port": 3000,
"url": "https://localhost:3000/",
"cookieSecret": "F1FEE670-3C72-11E4-916C-0800200C9A66",
"remoting": {
"context": {
"enableHttpContext": false
},
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"errorHandler": {
"disableStackTrace": false
}
},
"legacyExplorer": false
}
4 changes: 4 additions & 0 deletions server/datasources.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"db": {
"name": "db",
"connector": "memory"
},
"transient": {
"name": "transient",
"connector": "transient"
}
}
37 changes: 37 additions & 0 deletions server/middleware.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"initial:before": {
"loopback#favicon": {}
},
"initial": {
"compression": {},
"cors": {
"params": {
"origin": true,
"credentials": true,
"maxAge": 86400
}
}
},
"session": {
},
"auth": {
},
"parse": {
},
"routes": {
"loopback#rest": {
"paths": ["${restApiRoot}"]
}
},
"files": {
"loopback#static": {
"params": "$!../client/app"
}
},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"loopback#errorHandler": {}
}
}
14 changes: 14 additions & 0 deletions server/middleware.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files": {
"loopback#static": {
"params": "$!../dist/"
}
},
"final:after": {
"loopback#errorHandler": {
"params": {
"includeStack": false
}
}
}
}
8 changes: 8 additions & 0 deletions server/model-config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models",
"../node_modules/loopback-component-passport/lib/models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"User": {
Expand Down
64 changes: 15 additions & 49 deletions server/server.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,26 @@
'use strict';

var loopback = require('loopback');
var boot = require('loopback-boot');
var path = require('path');
var app = module.exports = loopback();
var env = require('get-env')({
test: 'test'
});

// Set up the /favicon.ico
app.use(loopback.favicon());

// request pre-processing middleware
app.use(loopback.compress());

// -- Add your pre-processing middleware here --


// boot scripts mount components like REST API
boot(app, __dirname);


// -- Mount static files here--
// All static middleware should be registered at the end, as all requests
// passing the static middleware are hitting the file system
// Example:

var staticPath = null;

if (env !== 'prod') {
staticPath = path.resolve(__dirname, '../client/app/');
console.log("Running app in development mode");
} else {
staticPath = path.resolve(__dirname, '../dist/');
console.log("Running app in prodction mode");
}

app.use(loopback.static(staticPath));

// Requests that get this far won't be handled
// by any middleware. Convert them into a 404 error
// that will be handled later down the chain.
app.use(loopback.urlNotFound());

// The ultimate error handler.
app.use(loopback.errorHandler());

app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
console.log('Web server listening at: %s', app.get('url'));
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};

// start the server if `$ node server.js`
if (require.main === module) {
app.start();
}
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;

// start the server if `$ node server.js`
if (require.main === module)
app.start();
});

0 comments on commit 729057c

Please sign in to comment.