mirror of https://github.com/status-im/metro.git
Updates from Thu Mar 5
- [react_native] JS files for D1885531 | Martin Konicek - Ported TabBarIOS to OSS and unified implementation | Nick Lockwood - [react-packager] Add minify option as query param | Amjad Masad - [ReactNative] Fix ExpandingText prop types | Christopher Chedeau - [react-packager] Make dev a query param option | Amjad Masad
This commit is contained in:
parent
7485aaf5fd
commit
806e82795a
|
@ -29,10 +29,6 @@ var options = parseCommandLine([{
|
||||||
}, {
|
}, {
|
||||||
command: 'root',
|
command: 'root',
|
||||||
description: 'add another root(s) to be used by the packager in this project',
|
description: 'add another root(s) to be used by the packager in this project',
|
||||||
}, {
|
|
||||||
command: 'dev',
|
|
||||||
default: true,
|
|
||||||
description: 'produce development packages with extra warnings enabled',
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
if (!options.projectRoots) {
|
if (!options.projectRoots) {
|
||||||
|
@ -97,7 +93,6 @@ function openStackFrameInEditor(req, res, next) {
|
||||||
|
|
||||||
function getAppMiddleware(options) {
|
function getAppMiddleware(options) {
|
||||||
return ReactPackager.middleware({
|
return ReactPackager.middleware({
|
||||||
dev: options.dev,
|
|
||||||
projectRoots: options.projectRoots,
|
projectRoots: options.projectRoots,
|
||||||
blacklistRE: blacklist(false),
|
blacklistRE: blacklist(false),
|
||||||
cacheVersion: '2',
|
cacheVersion: '2',
|
||||||
|
@ -106,7 +101,7 @@ function getAppMiddleware(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function runServer(
|
function runServer(
|
||||||
options, /* {string projectRoot, bool web, bool dev} */
|
options, /* {[]string projectRoot, bool web} */
|
||||||
readyCallback
|
readyCallback
|
||||||
) {
|
) {
|
||||||
var app = connect()
|
var app = connect()
|
||||||
|
|
|
@ -24,7 +24,6 @@ describe('HasteDependencyResolver', function() {
|
||||||
|
|
||||||
var depResolver = new HasteDependencyResolver({
|
var depResolver = new HasteDependencyResolver({
|
||||||
projectRoot: '/root',
|
projectRoot: '/root',
|
||||||
dev: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Is there a better way? How can I mock the prototype instead?
|
// Is there a better way? How can I mock the prototype instead?
|
||||||
|
@ -36,7 +35,7 @@ describe('HasteDependencyResolver', function() {
|
||||||
return q();
|
return q();
|
||||||
});
|
});
|
||||||
|
|
||||||
return depResolver.getDependencies('/root/index.js')
|
return depResolver.getDependencies('/root/index.js', { dev: false })
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
expect(result.mainModuleId).toEqual('index');
|
expect(result.mainModuleId).toEqual('index');
|
||||||
expect(result.dependencies).toEqual([
|
expect(result.dependencies).toEqual([
|
||||||
|
@ -85,7 +84,6 @@ describe('HasteDependencyResolver', function() {
|
||||||
|
|
||||||
var depResolver = new HasteDependencyResolver({
|
var depResolver = new HasteDependencyResolver({
|
||||||
projectRoot: '/root',
|
projectRoot: '/root',
|
||||||
dev: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Is there a better way? How can I mock the prototype instead?
|
// Is there a better way? How can I mock the prototype instead?
|
||||||
|
@ -97,7 +95,7 @@ describe('HasteDependencyResolver', function() {
|
||||||
return q();
|
return q();
|
||||||
});
|
});
|
||||||
|
|
||||||
return depResolver.getDependencies('/root/index.js')
|
return depResolver.getDependencies('/root/index.js', { dev: true })
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
expect(result.mainModuleId).toEqual('index');
|
expect(result.mainModuleId).toEqual('index');
|
||||||
expect(result.dependencies).toEqual([
|
expect(result.dependencies).toEqual([
|
||||||
|
@ -147,7 +145,6 @@ describe('HasteDependencyResolver', function() {
|
||||||
var depResolver = new HasteDependencyResolver({
|
var depResolver = new HasteDependencyResolver({
|
||||||
projectRoot: '/root',
|
projectRoot: '/root',
|
||||||
polyfillModuleNames: ['some module'],
|
polyfillModuleNames: ['some module'],
|
||||||
dev: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Is there a better way? How can I mock the prototype instead?
|
// Is there a better way? How can I mock the prototype instead?
|
||||||
|
@ -159,7 +156,7 @@ describe('HasteDependencyResolver', function() {
|
||||||
return q();
|
return q();
|
||||||
});
|
});
|
||||||
|
|
||||||
return depResolver.getDependencies('/root/index.js')
|
return depResolver.getDependencies('/root/index.js', { dev: false })
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
expect(result.mainModuleId).toEqual('index');
|
expect(result.mainModuleId).toEqual('index');
|
||||||
expect(result.dependencies).toEqual([
|
expect(result.dependencies).toEqual([
|
||||||
|
@ -218,7 +215,6 @@ describe('HasteDependencyResolver', function() {
|
||||||
it('should ', function() {
|
it('should ', function() {
|
||||||
var depResolver = new HasteDependencyResolver({
|
var depResolver = new HasteDependencyResolver({
|
||||||
projectRoot: '/root',
|
projectRoot: '/root',
|
||||||
dev: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var depGraph = depResolver._depGraph;
|
var depGraph = depResolver._depGraph;
|
||||||
|
|
|
@ -32,10 +32,6 @@ var validateOpts = declareOpts({
|
||||||
type: 'array',
|
type: 'array',
|
||||||
default: [],
|
default: [],
|
||||||
},
|
},
|
||||||
dev: {
|
|
||||||
type: 'boolean',
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
nonPersistent: {
|
nonPersistent: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -62,20 +58,20 @@ function HasteDependencyResolver(options) {
|
||||||
fileWatcher: this._fileWatcher
|
fileWatcher: this._fileWatcher
|
||||||
});
|
});
|
||||||
|
|
||||||
this._polyfillModuleNames = [
|
|
||||||
opts.dev
|
this._polyfillModuleNames = opts.polyfillModuleNames || [];
|
||||||
? path.join(__dirname, 'polyfills/prelude_dev.js')
|
|
||||||
: path.join(__dirname, 'polyfills/prelude.js'),
|
|
||||||
path.join(__dirname, 'polyfills/require.js'),
|
|
||||||
path.join(__dirname, 'polyfills/polyfills.js'),
|
|
||||||
path.join(__dirname, 'polyfills/console.js'),
|
|
||||||
path.join(__dirname, 'polyfills/error-guard.js'),
|
|
||||||
].concat(
|
|
||||||
opts.polyfillModuleNames || []
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HasteDependencyResolver.prototype.getDependencies = function(main) {
|
var getDependenciesValidateOpts = declareOpts({
|
||||||
|
dev: {
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
HasteDependencyResolver.prototype.getDependencies = function(main, options) {
|
||||||
|
var opts = getDependenciesValidateOpts(options);
|
||||||
|
|
||||||
var depGraph = this._depGraph;
|
var depGraph = this._depGraph;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
@ -84,7 +80,7 @@ HasteDependencyResolver.prototype.getDependencies = function(main) {
|
||||||
var dependencies = depGraph.getOrderedDependencies(main);
|
var dependencies = depGraph.getOrderedDependencies(main);
|
||||||
var mainModuleId = dependencies[0].id;
|
var mainModuleId = dependencies[0].id;
|
||||||
|
|
||||||
self._prependPolyfillDependencies(dependencies);
|
self._prependPolyfillDependencies(dependencies, opts.dev);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mainModuleId: mainModuleId,
|
mainModuleId: mainModuleId,
|
||||||
|
@ -94,10 +90,19 @@ HasteDependencyResolver.prototype.getDependencies = function(main) {
|
||||||
};
|
};
|
||||||
|
|
||||||
HasteDependencyResolver.prototype._prependPolyfillDependencies = function(
|
HasteDependencyResolver.prototype._prependPolyfillDependencies = function(
|
||||||
dependencies
|
dependencies,
|
||||||
|
isDev
|
||||||
) {
|
) {
|
||||||
var polyfillModuleNames = this._polyfillModuleNames;
|
var polyfillModuleNames = [
|
||||||
if (polyfillModuleNames.length > 0) {
|
isDev
|
||||||
|
? path.join(__dirname, 'polyfills/prelude_dev.js')
|
||||||
|
: path.join(__dirname, 'polyfills/prelude.js'),
|
||||||
|
path.join(__dirname, 'polyfills/require.js'),
|
||||||
|
path.join(__dirname, 'polyfills/polyfills.js'),
|
||||||
|
path.join(__dirname, 'polyfills/console.js'),
|
||||||
|
path.join(__dirname, 'polyfills/error-guard.js'),
|
||||||
|
].concat(this._polyfillModuleNames);
|
||||||
|
|
||||||
var polyfillModules = polyfillModuleNames.map(
|
var polyfillModules = polyfillModuleNames.map(
|
||||||
function(polyfillModuleName, idx) {
|
function(polyfillModuleName, idx) {
|
||||||
return new ModuleDescriptor({
|
return new ModuleDescriptor({
|
||||||
|
@ -109,7 +114,6 @@ HasteDependencyResolver.prototype._prependPolyfillDependencies = function(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
dependencies.unshift.apply(dependencies, polyfillModules);
|
dependencies.unshift.apply(dependencies, polyfillModules);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
HasteDependencyResolver.prototype.wrapModule = function(module, code) {
|
HasteDependencyResolver.prototype.wrapModule = function(module, code) {
|
||||||
|
|
|
@ -34,10 +34,6 @@ var validateOpts = declareOpts({
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
dev: {
|
|
||||||
type: 'boolean',
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
transformModulePath: {
|
transformModulePath: {
|
||||||
type:'string',
|
type:'string',
|
||||||
required: false,
|
required: false,
|
||||||
|
|
|
@ -7,6 +7,7 @@ var UglifyJS = require('uglify-js');
|
||||||
module.exports = Package;
|
module.exports = Package;
|
||||||
|
|
||||||
function Package(sourceMapUrl) {
|
function Package(sourceMapUrl) {
|
||||||
|
this._finalized = false;
|
||||||
this._modules = [];
|
this._modules = [];
|
||||||
this._sourceMapUrl = sourceMapUrl;
|
this._sourceMapUrl = sourceMapUrl;
|
||||||
}
|
}
|
||||||
|
@ -40,23 +41,56 @@ Package.prototype.finalize = function(options) {
|
||||||
|
|
||||||
Object.freeze(this._modules);
|
Object.freeze(this._modules);
|
||||||
Object.seal(this._modules);
|
Object.seal(this._modules);
|
||||||
|
this._finalized = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Package.prototype.getSource = function(options) {
|
Package.prototype._assertFinalized = function() {
|
||||||
if (!this._source) {
|
if (!this._finalized) {
|
||||||
options = options || {};
|
throw new Error('Package need to be finalized before getting any source');
|
||||||
this._source = _.pluck(this._modules, 'transformedCode').join('\n');
|
|
||||||
if (options.inlineSourceMap) {
|
|
||||||
var sourceMap = this.getSourceMap({excludeSource: true});
|
|
||||||
this._source += '\nRAW_SOURCE_MAP = ' + JSON.stringify(sourceMap) + ';';
|
|
||||||
}
|
}
|
||||||
this._source += '\n\/\/@ sourceMappingURL=' + this._sourceMapUrl;
|
};
|
||||||
|
|
||||||
|
Package.prototype._getSource = function() {
|
||||||
|
if (this._source == null) {
|
||||||
|
this._source = _.pluck(this._modules, 'transformedCode').join('\n');
|
||||||
}
|
}
|
||||||
return this._source;
|
return this._source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Package.prototype._getInlineSourceMap = function() {
|
||||||
|
if (this._inlineSourceMap == null) {
|
||||||
|
var sourceMap = this.getSourceMap({excludeSource: true});
|
||||||
|
this._inlineSourceMap = '\nRAW_SOURCE_MAP = ' +
|
||||||
|
JSON.stringify(sourceMap) + ';';
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._inlineSourceMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
Package.prototype.getSource = function(options) {
|
||||||
|
this._assertFinalized();
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
if (options.minify) {
|
||||||
|
return this.getMinifiedSourceAndMap().code;
|
||||||
|
}
|
||||||
|
|
||||||
|
var source = this._getSource();
|
||||||
|
|
||||||
|
if (options.inlineSourceMap) {
|
||||||
|
source += this._getInlineSourceMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
source += '\n\/\/@ sourceMappingURL=' + this._sourceMapUrl;
|
||||||
|
|
||||||
|
return source;
|
||||||
|
};
|
||||||
|
|
||||||
Package.prototype.getMinifiedSourceAndMap = function() {
|
Package.prototype.getMinifiedSourceAndMap = function() {
|
||||||
var source = this.getSource({inlineSourceMap: false});
|
this._assertFinalized();
|
||||||
|
|
||||||
|
var source = this._getSource();
|
||||||
try {
|
try {
|
||||||
return UglifyJS.minify(source, {
|
return UglifyJS.minify(source, {
|
||||||
fromString: true,
|
fromString: true,
|
||||||
|
@ -88,6 +122,8 @@ Package.prototype.getMinifiedSourceAndMap = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Package.prototype.getSourceMap = function(options) {
|
Package.prototype.getSourceMap = function(options) {
|
||||||
|
this._assertFinalized();
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var mappings = this._getMappings();
|
var mappings = this._getMappings();
|
||||||
var map = {
|
var map = {
|
||||||
|
@ -102,7 +138,6 @@ Package.prototype.getSourceMap = function(options) {
|
||||||
return map;
|
return map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Package.prototype._getMappings = function() {
|
Package.prototype._getMappings = function() {
|
||||||
var modules = this._modules;
|
var modules = this._modules;
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,6 @@ var validateOpts = declareOpts({
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
dev: {
|
|
||||||
type: 'boolean',
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
transformModulePath: {
|
transformModulePath: {
|
||||||
type:'string',
|
type:'string',
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -59,7 +55,6 @@ function Packager(options) {
|
||||||
projectRoots: opts.projectRoots,
|
projectRoots: opts.projectRoots,
|
||||||
blacklistRE: opts.blacklistRE,
|
blacklistRE: opts.blacklistRE,
|
||||||
polyfillModuleNames: opts.polyfillModuleNames,
|
polyfillModuleNames: opts.polyfillModuleNames,
|
||||||
dev: opts.dev,
|
|
||||||
nonPersistent: opts.nonPersistent,
|
nonPersistent: opts.nonPersistent,
|
||||||
moduleFormat: opts.moduleFormat
|
moduleFormat: opts.moduleFormat
|
||||||
});
|
});
|
||||||
|
@ -69,7 +64,6 @@ function Packager(options) {
|
||||||
blacklistRE: opts.blacklistRE,
|
blacklistRE: opts.blacklistRE,
|
||||||
cacheVersion: opts.cacheVersion,
|
cacheVersion: opts.cacheVersion,
|
||||||
resetCache: opts.resetCache,
|
resetCache: opts.resetCache,
|
||||||
dev: opts.dev,
|
|
||||||
transformModulePath: opts.transformModulePath,
|
transformModulePath: opts.transformModulePath,
|
||||||
nonPersistent: opts.nonPersistent,
|
nonPersistent: opts.nonPersistent,
|
||||||
});
|
});
|
||||||
|
@ -82,14 +76,14 @@ Packager.prototype.kill = function() {
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
Packager.prototype.package = function(main, runModule, sourceMapUrl) {
|
Packager.prototype.package = function(main, runModule, sourceMapUrl, isDev) {
|
||||||
var transformModule = this._transformModule.bind(this);
|
var transformModule = this._transformModule.bind(this);
|
||||||
var ppackage = new Package(sourceMapUrl);
|
var ppackage = new Package(sourceMapUrl);
|
||||||
|
|
||||||
var findEventId = Activity.startEvent('find dependencies');
|
var findEventId = Activity.startEvent('find dependencies');
|
||||||
var transformEventId;
|
var transformEventId;
|
||||||
|
|
||||||
return this.getDependencies(main)
|
return this.getDependencies(main, isDev)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
Activity.endEvent(findEventId);
|
Activity.endEvent(findEventId);
|
||||||
transformEventId = Activity.startEvent('transform');
|
transformEventId = Activity.startEvent('transform');
|
||||||
|
@ -119,8 +113,8 @@ Packager.prototype.invalidateFile = function(filePath) {
|
||||||
this._transformer.invalidateFile(filePath);
|
this._transformer.invalidateFile(filePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
Packager.prototype.getDependencies = function(main) {
|
Packager.prototype.getDependencies = function(main, isDev) {
|
||||||
return this._resolver.getDependencies(main);
|
return this._resolver.getDependencies(main, { dev: isDev });
|
||||||
};
|
};
|
||||||
|
|
||||||
Packager.prototype._transformModule = function(module) {
|
Packager.prototype._transformModule = function(module) {
|
||||||
|
|
|
@ -35,10 +35,6 @@ var validateOpts = declareOpts({
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
dev: {
|
|
||||||
type: 'boolean',
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
transformModulePath: {
|
transformModulePath: {
|
||||||
type:'string',
|
type:'string',
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -51,7 +47,6 @@ var validateOpts = declareOpts({
|
||||||
|
|
||||||
function Server(options) {
|
function Server(options) {
|
||||||
var opts = validateOpts(options);
|
var opts = validateOpts(options);
|
||||||
this._dev = opts.dev;
|
|
||||||
this._projectRoots = opts.projectRoots;
|
this._projectRoots = opts.projectRoots;
|
||||||
this._packages = Object.create(null);
|
this._packages = Object.create(null);
|
||||||
this._packager = new Packager(opts);
|
this._packager = new Packager(opts);
|
||||||
|
@ -73,14 +68,16 @@ Server.prototype._onFileChange = function(type, filepath, root) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype._rebuildPackages = function() {
|
Server.prototype._rebuildPackages = function() {
|
||||||
var dev = this._dev;
|
|
||||||
var buildPackage = this._buildPackage.bind(this);
|
var buildPackage = this._buildPackage.bind(this);
|
||||||
var packages = this._packages;
|
var packages = this._packages;
|
||||||
Object.keys(packages).forEach(function(key) {
|
Object.keys(packages).forEach(function(key) {
|
||||||
var options = getOptionsFromUrl(key);
|
var options = getOptionsFromUrl(key);
|
||||||
packages[key] = buildPackage(options).then(function(p) {
|
packages[key] = buildPackage(options).then(function(p) {
|
||||||
// Make a throwaway call to getSource to cache the source string.
|
// Make a throwaway call to getSource to cache the source string.
|
||||||
p.getSource({inlineSourceMap: dev});
|
p.getSource({
|
||||||
|
inlineSourceMap: options.dev,
|
||||||
|
minify: options.minify,
|
||||||
|
});
|
||||||
return p;
|
return p;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -97,7 +94,8 @@ Server.prototype._buildPackage = function(options) {
|
||||||
return this._packager.package(
|
return this._packager.package(
|
||||||
options.main,
|
options.main,
|
||||||
options.runModule,
|
options.runModule,
|
||||||
options.sourceMapUrl
|
options.sourceMapUrl,
|
||||||
|
options.dev
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,11 +164,13 @@ Server.prototype.processRequest = function(req, res, next) {
|
||||||
var building = this._packages[req.url] || this._buildPackage(options);
|
var building = this._packages[req.url] || this._buildPackage(options);
|
||||||
|
|
||||||
this._packages[req.url] = building;
|
this._packages[req.url] = building;
|
||||||
var dev = this._dev;
|
|
||||||
building.then(
|
building.then(
|
||||||
function(p) {
|
function(p) {
|
||||||
if (requestType === 'bundle') {
|
if (requestType === 'bundle') {
|
||||||
res.end(p.getSource({inlineSourceMap: dev}));
|
res.end(p.getSource({
|
||||||
|
inlineSourceMap: options.dev,
|
||||||
|
minify: options.minify,
|
||||||
|
}));
|
||||||
Activity.endEvent(startReqEventId);
|
Activity.endEvent(startReqEventId);
|
||||||
} else if (requestType === 'map') {
|
} else if (requestType === 'map') {
|
||||||
res.end(JSON.stringify(p.getSourceMap()));
|
res.end(JSON.stringify(p.getSourceMap()));
|
||||||
|
@ -196,8 +196,9 @@ function getOptionsFromUrl(reqUrl) {
|
||||||
return {
|
return {
|
||||||
sourceMapUrl: urlObj.pathname.replace(/\.bundle$/, '.map'),
|
sourceMapUrl: urlObj.pathname.replace(/\.bundle$/, '.map'),
|
||||||
main: main,
|
main: main,
|
||||||
runModule: urlObj.query.runModule === 'true' ||
|
dev: getBoolOptionFromQuery(urlObj.query, 'dev'),
|
||||||
urlObj.query.runModule === '1' ||
|
minify: getBoolOptionFromQuery(urlObj.query, 'minify'),
|
||||||
|
runModule: getBoolOptionFromQuery(urlObj.query, 'runModule') ||
|
||||||
// Backwards compatibility.
|
// Backwards compatibility.
|
||||||
urlObj.pathname.split('.').some(function(part) {
|
urlObj.pathname.split('.').some(function(part) {
|
||||||
return part === 'runModule';
|
return part === 'runModule';
|
||||||
|
@ -205,6 +206,10 @@ function getOptionsFromUrl(reqUrl) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBoolOptionFromQuery(query, opt) {
|
||||||
|
return query[opt] === 'true' || query[opt] === '1';
|
||||||
|
}
|
||||||
|
|
||||||
function handleError(res, error) {
|
function handleError(res, error) {
|
||||||
res.writeHead(500, {
|
res.writeHead(500, {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
|
|
|
@ -42,6 +42,8 @@ module.exports = function(descriptor) {
|
||||||
var schema = Joi.object().keys(joiKeys);
|
var schema = Joi.object().keys(joiKeys);
|
||||||
|
|
||||||
return function(opts) {
|
return function(opts) {
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
var res = Joi.validate(opts, schema, {
|
var res = Joi.validate(opts, schema, {
|
||||||
abortEarly: true,
|
abortEarly: true,
|
||||||
allowUnknown: false,
|
allowUnknown: false,
|
||||||
|
|
Loading…
Reference in New Issue