New constants/config merge system

This commit is contained in:
Cadence Fish
2020-01-28 16:14:21 +13:00
parent fb6081a719
commit cf8fd6b86b
8 changed files with 43 additions and 9 deletions

View File

@@ -1,7 +1,20 @@
module.exports = {
image_cache_control: `public, max-age=${7*24*60*60}`,
resource_cache_time: 30*60*1000,
/*
Welcome to the constants file!
Copy a key and provide a new value in /config.js to override the value here.
Please read the comments above every section!
*/
let constants = {
// Things that server owners _should_ change!
website_origin: "http://localhost:10407",
// Things that server owners _could_ change if they want to.
caching: {
image_cache_control: `public, max-age=${7*24*60*60}`,
resource_cache_time: 30*60*1000
},
// Instagram uses this stuff. This shouldn't be changed, except to fix a bug that hasn't yet been fixed upstream.
external: {
timeline_query_hash: "e769aa130647d2354c40ea6a439bfc08",
shortcode_query_hash: "2b0673e0dc4580674a88d426fe00ea90",
@@ -10,6 +23,7 @@ module.exports = {
shortcode_regex: "[\\w-]+"
},
// My code uses this stuff. Server owners have no reason to change it.
symbols: {
NO_MORE_PAGES: Symbol("NO_MORE_PAGES"),
TYPE_IMAGE: Symbol("TYPE_IMAGE"),
@@ -21,3 +35,9 @@ module.exports = {
NO_SHARED_DATA: Symbol("NO_SHARED_DATA")
}
}
// Override values from config and export the result
const md = require("mixin-deep")
const config = require("../../config")
constants = md(constants, config)
module.exports = constants