-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:jwetzell/showbridge
- Loading branch information
Showing
4 changed files
with
321 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"http": { | ||
"params": { | ||
"port": 3000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"ws": { | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"osc": { | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"midi": { | ||
"params": { | ||
"virtualInputName": "showbridge Input", | ||
"virtualOutputName": "showbridge Output" | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"udp": { | ||
"params": { | ||
"port": 8000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"tcp": { | ||
"params": { | ||
"port": 8000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"mqtt": { | ||
"params": { | ||
"broker": "", | ||
"topics": [] | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"cloud": { | ||
"params": { | ||
"url": "", | ||
"rooms": [] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"http": { | ||
"params": { | ||
"port": 3000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"ws": { | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"osc": { | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"midi": { | ||
"params": { | ||
"virtualInputName": "showbridge Input", | ||
"virtualOutputName": "showbridge Output" | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"udp": { | ||
"params": { | ||
"port": 8000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"tcp": { | ||
"params": { | ||
"port": 8000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"mqtt": { | ||
"params": { | ||
"broker": "", | ||
"topics": [] | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"cloud": { | ||
"params": { | ||
"url": "", | ||
"room": "test" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import assert from 'node:assert'; | ||
import { readFileSync } from 'node:fs'; | ||
import path from 'node:path'; | ||
import { describe, test } from 'node:test'; | ||
import Config from '../../src/config.js'; | ||
describe('Config', () => { | ||
// TODO(jwetzell): find better way to load schema | ||
|
||
test('create', () => { | ||
const schema = JSON.parse(readFileSync(path.join(import.meta.dirname, '../../../schema/config.schema.json'))); | ||
const goodConfig = JSON.parse(readFileSync(path.join(import.meta.dirname, './good_config.json'))); | ||
const config = new Config(goodConfig, schema); | ||
|
||
assert.notStrictEqual(config, undefined); | ||
}); | ||
|
||
test('bad config', () => { | ||
const schema = JSON.parse(readFileSync(path.join(import.meta.dirname, '../../../schema/config.schema.json'))); | ||
const badConfig = JSON.parse(readFileSync(path.join(import.meta.dirname, './bad_config.json'))); | ||
|
||
assert.throws(() => { | ||
const config = new Config(badConfig, schema); | ||
}); | ||
}); | ||
|
||
test('cloud room migration', () => { | ||
const schema = JSON.parse(readFileSync(path.join(import.meta.dirname, '../../../schema/config.schema.json'))); | ||
const cloudSingleRoomConfig = JSON.parse( | ||
readFileSync(path.join(import.meta.dirname, './cloud_single_room_config.json')) | ||
); | ||
|
||
const config = new Config(cloudSingleRoomConfig, schema); | ||
assert.deepStrictEqual(config.cloud.params.rooms, ['test']); | ||
}); | ||
|
||
test('getTriggers', () => { | ||
const schema = JSON.parse(readFileSync(path.join(import.meta.dirname, '../../../schema/config.schema.json'))); | ||
const goodConfig = JSON.parse(readFileSync(path.join(import.meta.dirname, './good_config.json'))); | ||
const config = new Config(goodConfig, schema); | ||
|
||
assert.notStrictEqual(config, undefined); | ||
assert.strictEqual(config.getTriggers('http')[0].type, 'any'); | ||
assert.strictEqual(config.getTriggers('udp')[0].type, 'any'); | ||
assert.strictEqual(config.getTriggers('osc')[0], undefined); | ||
}); | ||
|
||
test('toJSON', () => { | ||
const schema = JSON.parse(readFileSync(path.join(import.meta.dirname, '../../../schema/config.schema.json'))); | ||
const goodConfig = JSON.parse(readFileSync(path.join(import.meta.dirname, './good_config.json'))); | ||
const config = new Config(goodConfig, schema); | ||
|
||
assert.notStrictEqual(config, undefined); | ||
const toJSON = config.toJSON(); | ||
console.log(toJSON); | ||
assert.strictEqual(toJSON.http.triggers[0].comment, undefined); | ||
assert.strictEqual(toJSON.http.triggers[0].type, 'any'); | ||
assert.strictEqual(toJSON.osc.triggers[0], undefined); | ||
assert.strictEqual(toJSON.ws.triggers[0].actions[0].type, 'log'); | ||
assert.strictEqual(toJSON.ws.triggers[0].actions[0].comment, undefined); | ||
assert.strictEqual(toJSON.ws.triggers[0].actions[0].transforms.length, 0); | ||
assert.strictEqual(toJSON.$schema, undefined); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"$schema": "./config.schema.json", | ||
"http": { | ||
"params": { | ||
"port": 3000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"ws": { | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"osc": { | ||
"triggers": [] | ||
}, | ||
"midi": { | ||
"params": { | ||
"virtualInputName": "showbridge Input", | ||
"virtualOutputName": "showbridge Output" | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"udp": { | ||
"params": { | ||
"port": 8000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"tcp": { | ||
"params": { | ||
"port": 8000 | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"mqtt": { | ||
"params": { | ||
"broker": "", | ||
"topics": [] | ||
}, | ||
"triggers": [ | ||
{ | ||
"type": "any", | ||
"enabled": true, | ||
"actions": [{ "type": "log", "enabled": true }] | ||
} | ||
] | ||
}, | ||
"cloud": { | ||
"params": { | ||
"url": "", | ||
"rooms": [] | ||
} | ||
} | ||
} |