Skip to content

Commit f7497d7

Browse files
committed
feat: Allow custom configs when starting UMA server
1 parent a87fc35 commit f7497d7

4 files changed

Lines changed: 16 additions & 83 deletions

File tree

packages/uma/bin/demo.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/uma/bin/main.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ const { hideBin } = require('yargs/helpers');
44
const { ComponentsManager } = require('componentsjs');
55
const { setGlobalLoggerFactory, WinstonLoggerFactory } = require('global-logger-factory');
66

7+
const rootDir = path.join(__dirname, '../');
8+
79
const argv = yargs(hideBin(process.argv))
10+
.option('config', {
11+
alias: 'c',
12+
type: 'string',
13+
array: true,
14+
description: 'Components.js configuration file path(s)',
15+
default: [path.join(rootDir, './config/default.json')]
16+
})
817
.option('port', {
918
alias: 'p',
1019
type: 'number',
@@ -32,16 +41,14 @@ const argv = yargs(hideBin(process.argv))
3241
.alias('help', 'h')
3342
.argv;
3443

35-
const rootDir = path.join(__dirname, '../');
36-
3744
const launch = async () => {
3845
const variables = {};
3946

4047
variables['urn:uma:variables:port'] = argv.port;
4148
variables['urn:uma:variables:baseUrl'] = argv.baseUrl ?? `http://localhost:${argv.port}/uma`;
4249
variables['urn:uma:variables:backupFilePath'] = argv.backupFilePath;
43-
44-
const configPath = path.join(rootDir, './config/default.json');
50+
// Debug edge case for demo config
51+
variables['urn:uma:variables:policyContainer'] = 'http://localhost:3000/settings/policies/';
4552

4653
setGlobalLoggerFactory(new WinstonLoggerFactory(argv.loggingLevel));
4754

@@ -51,7 +58,9 @@ const launch = async () => {
5158
typeChecking: false,
5259
});
5360

54-
await manager.configRegistry.register(configPath);
61+
for (const configPath of argv.config) {
62+
await manager.configRegistry.register(configPath);
63+
}
5564

5665
const umaServer = await manager.instantiate('urn:uma:default:App',{variables});
5766
await umaServer.start();

packages/uma/bin/odrl.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/uma/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
"build:ts": "yarn run -T tsc",
5555
"build:components": "yarn run -T componentsjs-generator -r sai-uma -s src -c dist/components -i .componentsignore --lenient",
5656
"start": "node bin/main.js",
57-
"start:odrl": "node bin/odrl.js",
58-
"demo": "node bin/demo.js"
57+
"start:odrl": "node bin/main.js -c ./config/odrl.json -l silly",
58+
"demo": "node bin/main.js -c ./config/demo.json -l silly"
5959
},
6060
"dependencies": {
6161
"@comunica/query-sparql": "^4.4.1",

0 commit comments

Comments
 (0)