forked from GPII/first-discovery-server
-
Notifications
You must be signed in to change notification settings - Fork 2
/
firstDiscoveryServer.js
119 lines (111 loc) · 3.76 KB
/
firstDiscoveryServer.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
Copyright 2015 OCAD University
Licensed under the New BSD license. You may not use this file except in
compliance with this License.
You may obtain a copy of the License at
https://raw.githubusercontent.com/GPII/first-discovery-server/master/LICENSE.txt
*/
"use strict";
var fluid = require("infusion");
require("gpii-express");
require("./preferencesRouter.js");
require("./configUtils.js");
var path = require("path");
var fdDemosDir = path.resolve(__dirname, "../../node_modules/gpii-first-discovery/demos");
var fdSrcDir = path.resolve(__dirname, "../../node_modules/gpii-first-discovery/src");
fluid.defaults("gpii.firstDiscovery.server", {
gradeNames: ["gpii.express"],
port: 8088,
config: {
express: {
baseUrl: {
expander: {
funcName: "fluid.stringTemplate",
args: ["http://localhost:%port", {port: "{that}.options.config.express.port"}]
}
}
}
},
preferencesConfig: {},
components: {
json: {
type: "gpii.express.middleware.bodyparser.json"
},
demoRouter: {
type: "gpii.express.router.static",
options: {
path: "/demos",
content: fdDemosDir
}
},
srcRouter: {
type: "gpii.express.router.static",
options: {
path: "/src",
content: fdSrcDir
}
},
prefsRouter: {
type: "gpii.firstDiscovery.server.preferences.router",
options: {
path: "/user"
}
}
},
distributeOptions: [{
source: "{that}.options.port",
target: "{that}.options.config.express.port"
}, {
source: "{that}.options.preferencesConfig",
target: "{that gpii.firstDiscovery.server.preferences.handler}.options.config"
}]
});
fluid.defaults("gpii.firstDiscovery.server.configurator", {
gradeNames: ["gpii.schema"],
"components": {
"fdServer": {
"type": "gpii.firstDiscovery.server",
"createOnEvent": "validated"
}
},
"distributeOptions": [{
"source": "{that}.options.port",
"target": "{that fdServer}.options.port"
}, {
"source": "{that}.options.preferencesConfig",
"target": "{that fdServer}.options.preferencesConfig"
}],
"schema": {
"required": ["port", "preferencesConfig"],
"properties": {
"preferencesConfig": {
"required": ["securityServer", "authentication"],
"properties": {
"securityServer": {
"required": ["port", "hostname", "paths"],
"properties": {
"port": {"type": "string"},
"hostname": {"type": "string"},
"paths": {
"required": ["token", "preferences"],
"properties": {
"token": {"type": "string"},
"preferences": {"type": "string"}
}
}
}
},
"authentication": {
"required": ["grant_type", "scope", "client_id", "client_secret"],
"properties": {
"grant_type": {"type": "string"},
"scope": {"type": "string"},
"client_id": {"type": "string"},
"client_secret": {"type": "string"}
}
}
}
}
}
}
});