nfp_sites/api/config.mjs
2022-07-20 00:33:06 +00:00

185 lines
3.9 KiB
JavaScript

import _ from 'lodash'
import nconf from 'nconf-lite'
import { readFileSync } from 'fs'
// Helper method for global usage.
nconf.inTest = () => nconf.get('NODE_ENV') === 'test'
// Config follow the following priority check order:
// 1. Enviroment variables
// 2. package.json
// 3. config/config.json
// 4. config/config.default.json
// Load enviroment variables as first priority
nconf.env({
separator: '__',
whitelist: [
'DATABASE_URL',
'NODE_ENV',
'server__port',
'server__host',
'knex__connection__host',
'knex__connection__user',
'knex__connection__database',
'knex__connection__password',
'knex__connectionslave__host',
'knex__connectionslave__user',
'knex__connectionslave__database',
'knex__connectionslave__password',
'upload__baseurl',
'upload__port',
'upload__host',
'upload__name',
'upload__secret',
'bunyan__name',
'frontend__url',
'jwt__secret',
'sessionsecret',
'bcrypt',
'name',
'NODE_VERSION',
],
parseValues: true,
})
// Load empty overrides that can be overwritten later
nconf.overrides({})
nconf.defaults({
"NODE_ENV": "development",
"frontend": {
"url": "http://beta01.nfp.moe"
},
"jwtsecret": "w2bkdWAButfdfEkCs8dpE3L2n6QzCfhna0T4",
"mssql": {
"conn_timeout": 5,
"floor": 1,
"ceiling": 2,
"heartbeatSecs": 20,
"inactivityTimeoutSecs": 60,
"connectionString": "Driver={ODBC Driver 17 for SQL Server}; Server=localhost;UID=dev; PWD=dev; Database=nfp_moe",
},
"media": {
"secret": "upload-secret-key-here",
"iss": "dev",
"path": "https://media.nfp.is/media/resize",
"preview": {
"out": "base64",
"format": "avif",
"blur": 10,
"resize": {
"width": 300,
"height": 300,
"fit": "inside",
"withoutEnlargement": true,
"kernel": "lanczos3"
},
"avif": {
"quality": 50,
"effort": 4
}
},
"small": {
"jpeg": {
"format": "jpeg",
"resize": {
"width": 720,
"height": 720,
"fit": "inside",
"withoutEnlargement": true,
"kernel": "lanczos3"
},
"jpeg": {
"quality": 93
}
},
"avif": {
"format": "avif",
"resize": {
"width": 720,
"height": 720,
"fit": "inside",
"withoutEnlargement": true,
"kernel": "lanczos3"
},
"avif": {
"quality": 60,
"effort": 3
}
}
},
"medium": {
"jpeg": {
"format": "jpeg",
"resize": {
"width": 1300,
"height": 1300,
"fit": "inside",
"withoutEnlargement": true,
"kernel": "lanczos3"
},
"jpeg": {
"quality": 93
}
},
"avif": {
"format": "avif",
"resize": {
"width": 1300,
"height": 1300,
"fit": "inside",
"withoutEnlargement": true,
"kernel": "lanczos3"
},
"avif": {
"quality": 75,
"effort": 3
}
}
},
"large": {
"jpeg": {
"format": "jpeg",
"resize": {
"width": 3000,
"height": 3000,
"fit": "inside",
"withoutEnlargement": true,
"kernel": "lanczos3"
},
"jpeg": {
"quality": 95
}
},
"avif": {
"format": "avif",
"resize": {
"width": 3000,
"height": 3000,
"fit": "inside",
"withoutEnlargement": true,
"kernel": "lanczos3"
},
"avif": {
"quality": 85,
"effort": 3
}
}
},
},
"fileSize": 524288000,
"upload": {
"baseurl": "https://cdn.nfp.is",
"port": "2111",
"host": "storage01.nfp.is",
"name": "nfpmoe-dev",
"secret": "nfpmoe-dev"
}
})
export default nconf