diff options
| author | Ben Beltran <ben@nsovocal.com> | 2019-12-23 00:21:35 +0100 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2019-12-23 00:21:35 +0100 |
| commit | 2d5b700eb63669ca0a4bf27b5df58aa8af15735f (patch) | |
| tree | 2e11a0cc848cf3b0151385547bac7d405d347336 /config | |
| parent | a9b3b4d512421817cc34c4efe5f4d29a9453278d (diff) | |
Add backend files
Diffstat (limited to 'config')
| -rw-r--r-- | config/config.js | 49 | ||||
| -rw-r--r-- | config/env.dist | 2 |
2 files changed, 51 insertions, 0 deletions
diff --git a/config/config.js b/config/config.js new file mode 100644 index 0000000..32f27af --- /dev/null +++ b/config/config.js @@ -0,0 +1,49 @@ +import Getenv from 'getenv2'; +import Joi from 'joi'; + +/** + * The main configuration object for the Forum backend. It will be used to + * initialize all of the sub-components. It can extend any property of + * the forum object. + * + * @typedef {object} tForumBackendConfiguration + * @property {number} [port=1978] the port where the app will listen on + * @property {string} [staticDirectory=static] the path, relative to the + * project root, where static assets live + * @property {number} [ttl=180] the time in seconds that posts + * remain alive + * @property {tRethinkDBConfiguration} rethinkDB the configuration to + * connect to the rethinkDB server + * @property {tJWTConfiguration} jwt the configuration for the + * JWT authentication + */ +export default { + port: Getenv('FORUM_PORT', Joi.number().integer(), 1978), + staticDirectory: Getenv('FORUM_STATIC_DIRECTORY', Joi.string(), 'static'), + ttl: Getenv('FORUM_TTL', Joi.number().integer(), 180), + + /** + * Configures the behavior of the JWT token. + * + * @typedef {object} tJWTConfiguration + * @property {number} [duration=86400] the duration of the JWT in + * seconds + * @property {string} secret the secret used to sign the JWT + */ + jwt: { + duration: Getenv('FORUM_JWT_DURATION', Joi.number().integer(), 86400), + secret: Getenv('FORUM_JWT_SECRET', Joi.string()) + }, + + /** + * Information required to connect to the rethinkDB server + * + * @typedef {object} tRethinkDBConfiguration + * @property {string} host the location of the rethinkDB host + * @property {string} [post=6379] port where rethinkDB server is listening + */ + rethinkDB: { + host: Getenv('FORUM_RETHINK_DB_HOST', Joi.string()), + port: Getenv('FORUM_RETHINK_DB_PORT', Joi.number().integer(), 28015) + } +}; diff --git a/config/env.dist b/config/env.dist new file mode 100644 index 0000000..730b6f9 --- /dev/null +++ b/config/env.dist @@ -0,0 +1,2 @@ +FORUM_RETHINK_DB_HOST=location_of_rethink_db_server +FORUM_JWT_SECRET=some_random_string |