|
@@ -90,8 +90,8 @@ const DefaultModelServerConfig = {
|
|
* - filename [source, mapping]
|
|
* - filename [source, mapping]
|
|
* - URI [source, mapping, format]
|
|
* - URI [source, mapping, format]
|
|
*
|
|
*
|
|
- * Mapping is provided 'source' and 'id' variables to interpolate.
|
|
|
|
- *
|
|
|
|
|
|
+ * Mapping is provided 'source' and 'id' variables to interpolate.
|
|
|
|
+ *
|
|
* /static query uses 'pdb-cif' and 'pdb-bcif' source names.
|
|
* /static query uses 'pdb-cif' and 'pdb-bcif' source names.
|
|
*/
|
|
*/
|
|
sourceMap: [
|
|
sourceMap: [
|
|
@@ -152,7 +152,7 @@ function addServerArgs(parser: argparse.ArgumentParser) {
|
|
parser.addArgument([ '--defaultSource' ], {
|
|
parser.addArgument([ '--defaultSource' ], {
|
|
defaultValue: DefaultModelServerConfig.defaultSource,
|
|
defaultValue: DefaultModelServerConfig.defaultSource,
|
|
metavar: 'DEFAULT_SOURCE',
|
|
metavar: 'DEFAULT_SOURCE',
|
|
- help: `modifies which 'sourceMap' source to use by default`
|
|
|
|
|
|
+ help: `modifies which 'sourceMap' source to use by default`
|
|
});
|
|
});
|
|
parser.addArgument([ '--sourceMap' ], {
|
|
parser.addArgument([ '--sourceMap' ], {
|
|
nargs: 2,
|
|
nargs: 2,
|
|
@@ -182,7 +182,7 @@ function addServerArgs(parser: argparse.ArgumentParser) {
|
|
export type ModelServerConfig = typeof DefaultModelServerConfig
|
|
export type ModelServerConfig = typeof DefaultModelServerConfig
|
|
export const ModelServerConfig = { ...DefaultModelServerConfig }
|
|
export const ModelServerConfig = { ...DefaultModelServerConfig }
|
|
|
|
|
|
-export const ModelServerConfigTemplate: ModelServerConfig = {
|
|
|
|
|
|
+export const ModelServerConfigTemplate: ModelServerConfig = {
|
|
...DefaultModelServerConfig,
|
|
...DefaultModelServerConfig,
|
|
defaultSource: 'pdb-bcif',
|
|
defaultSource: 'pdb-bcif',
|
|
sourceMap: [
|
|
sourceMap: [
|
|
@@ -202,12 +202,12 @@ interface ServerJsonConfig {
|
|
}
|
|
}
|
|
|
|
|
|
function addJsonConfigArgs(parser: argparse.ArgumentParser) {
|
|
function addJsonConfigArgs(parser: argparse.ArgumentParser) {
|
|
- parser.addArgument(['--cfg'], {
|
|
|
|
|
|
+ parser.addArgument(['--cfg'], {
|
|
help: [
|
|
help: [
|
|
'JSON config file path',
|
|
'JSON config file path',
|
|
'If a property is not specified, cmd line param/OS variable/default value are used.'
|
|
'If a property is not specified, cmd line param/OS variable/default value are used.'
|
|
].join('\n'),
|
|
].join('\n'),
|
|
- required: false
|
|
|
|
|
|
+ required: false
|
|
});
|
|
});
|
|
parser.addArgument(['--printCfg'], { help: 'Print current config for validation and exit.', required: false, nargs: 0 });
|
|
parser.addArgument(['--printCfg'], { help: 'Print current config for validation and exit.', required: false, nargs: 0 });
|
|
parser.addArgument(['--cfgTemplate'], { help: 'Prints default JSON config template to be modified and exits.', required: false, nargs: 0 });
|
|
parser.addArgument(['--cfgTemplate'], { help: 'Prints default JSON config template to be modified and exits.', required: false, nargs: 0 });
|
|
@@ -228,7 +228,7 @@ function validateConfigAndSetupSourceMap() {
|
|
if (!ModelServerConfig.sourceMap || ModelServerConfig.sourceMap.length === 0) {
|
|
if (!ModelServerConfig.sourceMap || ModelServerConfig.sourceMap.length === 0) {
|
|
throw new Error(`Please provide 'sourceMap' configuration. See [-h] for available options.`);
|
|
throw new Error(`Please provide 'sourceMap' configuration. See [-h] for available options.`);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
mapSourceAndIdToFilename = new Function('source', 'id', [
|
|
mapSourceAndIdToFilename = new Function('source', 'id', [
|
|
'switch (source.toLowerCase()) {',
|
|
'switch (source.toLowerCase()) {',
|
|
...ModelServerConfig.sourceMap.map(([source, path, format]) => `case '${source.toLowerCase()}': return [\`${path}\`, '${format}'];`),
|
|
...ModelServerConfig.sourceMap.map(([source, path, format]) => `case '${source.toLowerCase()}': return [\`${path}\`, '${format}'];`),
|
|
@@ -254,23 +254,23 @@ export function configureServer() {
|
|
console.log(JSON.stringify(ModelServerConfigTemplate, null, 2));
|
|
console.log(JSON.stringify(ModelServerConfigTemplate, null, 2));
|
|
process.exit(0);
|
|
process.exit(0);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
try {
|
|
try {
|
|
setConfig(config) // sets the config for global use
|
|
setConfig(config) // sets the config for global use
|
|
-
|
|
|
|
|
|
+
|
|
if (config.cfg) {
|
|
if (config.cfg) {
|
|
const cfg = JSON.parse(fs.readFileSync(config.cfg, 'utf8')) as ModelServerConfig;
|
|
const cfg = JSON.parse(fs.readFileSync(config.cfg, 'utf8')) as ModelServerConfig;
|
|
setConfig(cfg);
|
|
setConfig(cfg);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (config.printCfg !== null) {
|
|
if (config.printCfg !== null) {
|
|
console.log(JSON.stringify(ModelServerConfig, null, 2));
|
|
console.log(JSON.stringify(ModelServerConfig, null, 2));
|
|
process.exit(0);
|
|
process.exit(0);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
validateConfigAndSetupSourceMap();
|
|
validateConfigAndSetupSourceMap();
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.error('' + e);
|
|
console.error('' + e);
|
|
process.exit(1);
|
|
process.exit(1);
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|