Remove peerDependencies, use express directly.
This commit is contained in:
parent
75713f16f2
commit
cbf768f0b8
32
index.js
32
index.js
|
@ -5,11 +5,8 @@
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var urlJoin = require('./lib/url-join');
|
var urlJoin = require('./lib/url-join');
|
||||||
var _defaults = require('lodash.defaults');
|
var _defaults = require('lodash.defaults');
|
||||||
var extend = require('util')._extend;
|
var express = require('express');
|
||||||
var loopback = require('loopback');
|
|
||||||
var express = requireLoopbackDependency('express');
|
|
||||||
var swagger = require('./lib/swagger');
|
var swagger = require('./lib/swagger');
|
||||||
var fs = require('fs');
|
|
||||||
var SWAGGER_UI_ROOT = path.join(__dirname, 'node_modules',
|
var SWAGGER_UI_ROOT = path.join(__dirname, 'node_modules',
|
||||||
'swagger-ui', 'dist');
|
'swagger-ui', 'dist');
|
||||||
var STATIC_ROOT = path.join(__dirname, 'public');
|
var STATIC_ROOT = path.join(__dirname, 'public');
|
||||||
|
@ -58,33 +55,12 @@ function explorer(loopbackApplication, options) {
|
||||||
// In this way one could e.g. make changes to index.html without having
|
// In this way one could e.g. make changes to index.html without having
|
||||||
// to worry about constantly pulling in JS updates.
|
// to worry about constantly pulling in JS updates.
|
||||||
if (options.swaggerDistRoot) {
|
if (options.swaggerDistRoot) {
|
||||||
app.use(loopback.static(options.swaggerDistRoot));
|
app.use(express.static(options.swaggerDistRoot));
|
||||||
}
|
}
|
||||||
// File in node_modules are overridden by a few customizations
|
// File in node_modules are overridden by a few customizations
|
||||||
app.use(loopback.static(STATIC_ROOT));
|
app.use(express.static(STATIC_ROOT));
|
||||||
// Swagger UI distribution
|
// Swagger UI distribution
|
||||||
app.use(loopback.static(SWAGGER_UI_ROOT));
|
app.use(express.static(SWAGGER_UI_ROOT));
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireLoopbackDependency(module) {
|
|
||||||
try {
|
|
||||||
return require('loopback/node_modules/' + module);
|
|
||||||
} catch (err) {
|
|
||||||
if (err.code !== 'MODULE_NOT_FOUND') throw err;
|
|
||||||
try {
|
|
||||||
// Dependencies may be installed outside the loopback module,
|
|
||||||
// e.g. as peer dependencies. Try to load the dependency from there.
|
|
||||||
return require(module);
|
|
||||||
} catch (errPeer) {
|
|
||||||
if (errPeer.code !== 'MODULE_NOT_FOUND') throw errPeer;
|
|
||||||
// Rethrow the initial error to make it clear that we were trying
|
|
||||||
// to load a module that should have been installed inside
|
|
||||||
// "loopback/node_modules". This should minimise end-user's confusion.
|
|
||||||
// However, such situation should never happen as `require('loopback')`
|
|
||||||
// would have failed before this function was even called.
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
10
package.json
10
package.json
|
@ -6,10 +6,6 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha"
|
"test": "mocha"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
|
||||||
"loopback": "2.x || 1.x >=1.5",
|
|
||||||
"strong-remoting": "2.x || 1.x >=1.5"
|
|
||||||
},
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/strongloop/loopback-explorer.git"
|
"url": "git://github.com/strongloop/loopback-explorer.git"
|
||||||
|
@ -28,8 +24,7 @@
|
||||||
"loopback": "1.x",
|
"loopback": "1.x",
|
||||||
"mocha": "~1.14.0",
|
"mocha": "~1.14.0",
|
||||||
"supertest": "~0.8.1",
|
"supertest": "~0.8.1",
|
||||||
"chai": "~1.8.1",
|
"chai": "~1.8.1"
|
||||||
"express": "3.x"
|
|
||||||
},
|
},
|
||||||
"license": {
|
"license": {
|
||||||
"name": "Dual MIT/StrongLoop",
|
"name": "Dual MIT/StrongLoop",
|
||||||
|
@ -39,6 +34,7 @@
|
||||||
"swagger-ui": "~2.0.17",
|
"swagger-ui": "~2.0.17",
|
||||||
"debug": "~1.0.2",
|
"debug": "~1.0.2",
|
||||||
"lodash.clonedeep": "^2.4.1",
|
"lodash.clonedeep": "^2.4.1",
|
||||||
"lodash.defaults": "^2.4.1"
|
"lodash.defaults": "^2.4.1",
|
||||||
|
"express": "4.x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue