-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.js
More file actions
69 lines (60 loc) · 1.95 KB
/
Copy pathmain.js
File metadata and controls
69 lines (60 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const path = require('path');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const { ComponentsManager } = require('componentsjs');
const { setGlobalLoggerFactory, WinstonLoggerFactory } = require('global-logger-factory');
const rootDir = path.join(__dirname, '../');
const argv = yargs(hideBin(process.argv))
.option('config', {
alias: 'c',
type: 'string',
array: true,
description: 'Components.js configuration file path(s)',
default: [path.join(rootDir, './config/default.json')]
})
.option('port', {
alias: 'p',
type: 'number',
description: 'Port number for the UMA server',
default: 4000
})
.option('baseUrl', {
alias: 'b',
type: 'string',
description: 'Base URL for the UMA server. Defaults to http://localhost:$PORT/uma',
})
.option('loggingLevel', {
alias: 'l',
type: 'string',
description: 'Log level for the UMA server',
default: 'info'
})
.option('backupFilePath', {
alias: 'f',
type: 'string',
description: 'Backup file path for the UMA server',
default: ''
})
.help()
.alias('help', 'h')
.argv;
const launch = async () => {
const variables = {};
variables['urn:uma:variables:port'] = argv.port;
variables['urn:uma:variables:baseUrl'] = argv.baseUrl ?? `http://localhost:${argv.port}/uma`;
variables['urn:uma:variables:backupFilePath'] = argv.backupFilePath;
// Debug edge case for demo config
variables['urn:uma:variables:policyContainer'] = 'http://localhost:3000/settings/policies/';
setGlobalLoggerFactory(new WinstonLoggerFactory(argv.loggingLevel));
const manager = await ComponentsManager.build({
mainModulePath: rootDir,
logLevel: argv.loggingLevel,
typeChecking: false,
});
for (const configPath of argv.config) {
await manager.configRegistry.register(configPath);
}
const umaServer = await manager.instantiate('urn:uma:default:App',{variables});
await umaServer.start();
};
launch();