adapt-authoring-config 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -50,4 +50,29 @@ $ NODE_ENV=dev npm start
|
|
|
50
50
|
> set NODE_ENV=dev | npm start
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
Please see the documentation for your own operating system for instructions on how to save environment variables in a more permanent way.
|
|
53
|
+
Please see the documentation for your own operating system for instructions on how to save environment variables in a more permanent way.
|
|
54
|
+
|
|
55
|
+
## Using environment variables for configuration
|
|
56
|
+
|
|
57
|
+
As an alternative to config files, any configuration option can be set via an environment variable using the following naming convention:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
ADAPT_AUTHORING_<MODULE>__<property>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- The module name is converted to uppercase with underscores replacing hyphens (e.g. `adapt-authoring-server` becomes `ADAPT_AUTHORING_SERVER`)
|
|
64
|
+
- A double underscore (`__`) separates the module name from the property name
|
|
65
|
+
- The property name is kept in its original camelCase format
|
|
66
|
+
|
|
67
|
+
For example:
|
|
68
|
+
|
|
69
|
+
| Environment variable | Config equivalent |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `ADAPT_AUTHORING_SERVER__host` | `adapt-authoring-server.host` |
|
|
72
|
+
| `ADAPT_AUTHORING_SERVER__port` | `adapt-authoring-server.port` |
|
|
73
|
+
| `ADAPT_AUTHORING_MONGODB__connectionUri` | `adapt-authoring-mongodb.connectionUri` |
|
|
74
|
+
| `ADAPT_AUTHORING_AUTH_LOCAL__saltRounds` | `adapt-authoring-auth-local.saltRounds` |
|
|
75
|
+
|
|
76
|
+
Values are parsed as JSON where possible, so non-string types like numbers and booleans can be set directly (e.g. `ADAPT_AUTHORING_SERVER__port=5678`).
|
|
77
|
+
|
|
78
|
+
Any environment variables that do not start with `ADAPT_AUTHORING_` are available under the `env` namespace (e.g. `NODE_ENV` becomes `env.NODE_ENV`).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Configuration reference
|
|
2
|
-
This page lists all configuration options supported by the [core bundle](coremodules) of Adapt authoring modules.
|
|
2
|
+
This page lists all configuration options supported by the [core bundle](coremodules) of Adapt authoring modules. For details on how to set up your configuration, including using environment variables, see [Configuring your environment](configure-environment).
|
|
3
3
|
|
|
4
4
|
{{{TABLE_OF_CONTENTS}}}
|
|
5
5
|
|
package/lib/ConfigModule.js
CHANGED
|
@@ -128,21 +128,21 @@ class ConfigModule extends AbstractModule {
|
|
|
128
128
|
return a.name.localeCompare(b.name)
|
|
129
129
|
})
|
|
130
130
|
const coreDep = deps.find(d => isCore(d))
|
|
131
|
-
if (coreDep)
|
|
131
|
+
if (coreDep) this.processModuleSchema(coreDep, jsonschema)
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
let hasErrored = false
|
|
134
|
+
for (const d of deps.filter(d => !isCore(d))) {
|
|
135
|
+
try {
|
|
136
|
+
this.processModuleSchema(d, jsonschema)
|
|
137
|
+
} catch (e) {
|
|
138
138
|
hasErrored = true
|
|
139
|
-
if (
|
|
140
|
-
console.log(`${
|
|
139
|
+
if (e?.data?.errors) {
|
|
140
|
+
console.log(`${e.modName}: ${e.data.errors}`)
|
|
141
141
|
} else {
|
|
142
|
-
console.log(
|
|
142
|
+
console.log(e)
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
}
|
|
145
|
+
}
|
|
146
146
|
if (hasErrored) throw new Error()
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -150,15 +150,14 @@ class ConfigModule extends AbstractModule {
|
|
|
150
150
|
* Processes and validates a single module config schema (checks the user config specifies any required fields, and that they are the expected type)
|
|
151
151
|
* @param {Object} pkg Package.json data
|
|
152
152
|
* @param {JsonSchemaModule} jsonschema Module instance for validation
|
|
153
|
-
* @return {Promise}
|
|
154
153
|
*/
|
|
155
|
-
|
|
154
|
+
processModuleSchema (pkg, jsonschema) {
|
|
156
155
|
if (!pkg.name || !pkg.rootDir) return
|
|
157
156
|
|
|
158
157
|
const schemaPath = path.resolve(pkg.rootDir, 'conf/config.schema.json')
|
|
159
158
|
let schema
|
|
160
159
|
try {
|
|
161
|
-
schema =
|
|
160
|
+
schema = jsonschema.createSchema(schemaPath).build()
|
|
162
161
|
} catch (e) {
|
|
163
162
|
return
|
|
164
163
|
}
|
|
@@ -168,7 +167,7 @@ class ConfigModule extends AbstractModule {
|
|
|
168
167
|
return { ...m, [k]: this.get(`${pkg.name}.${k}`) }
|
|
169
168
|
}, {})
|
|
170
169
|
try {
|
|
171
|
-
data =
|
|
170
|
+
data = schema.validate(data)
|
|
172
171
|
} catch (e) {
|
|
173
172
|
e.modName = pkg.name
|
|
174
173
|
throw e
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A configuration module for the Adapt authoring tool.",
|
|
5
5
|
"homepage": "https://github.com/adapt-security/adapt-authoring-config",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"glob": "^13.0.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"adapt-authoring-auth": "^
|
|
22
|
+
"adapt-authoring-auth": "^2.0.0",
|
|
23
23
|
"adapt-authoring-errors": "^1.1.2",
|
|
24
24
|
"adapt-authoring-jsonschema": "^1.2.0",
|
|
25
25
|
"adapt-authoring-server": "^2.0.0"
|