diff options
author | Alexis Hovorka <[email protected]> | 2024-02-17 00:42:20 -0700 |
---|---|---|
committer | Alexis Hovorka <[email protected]> | 2024-02-17 00:42:20 -0700 |
commit | 8f44593d55c82197854d9e29174fe66c4e50ebde (patch) | |
tree | a43a6d763517d1304076897952b1111886303158 /app/config.js | |
parent | c5aa364e0e372d0e29063a27bd17811446db8b6a (diff) |
[refactor] Switch to ES Modules
Diffstat (limited to 'app/config.js')
-rw-r--r-- | app/config.js | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/app/config.js b/app/config.js index b7212e3..f137cc4 100644 --- a/app/config.js +++ b/app/config.js @@ -1,34 +1,24 @@ -"use strict"; +import {clamp, deepFreeze} from "./utils.js"; -function deepFreeze(obj) { - for (const name of Reflect.ownKeys(obj)) { - const value = obj[name]; - if ((value && typeof value === "object") || - typeof value === "function") deepFreeze(value); - } return Object.freeze(obj); -} +export const PORT = clamp(+process.env.PORT||8080, 1, 65535); +export const HOST = process.env.HOST||"0.0.0.0"; +export const DOMAIN = "localhost"; +export const SECURE = false; // i.e. served over https -Math.clamp ||= ((x,l,h) => Math.max(l,Math.min(x,h))); - -module.exports = deepFreeze({ - PORT: Math.clamp(+process.env.PORT||8080, 1, 65535), - HOST: process.env.HOST||"0.0.0.0", - DOMAIN: "localhost", - SECURE: false, // i.e. served over https - - auth: { - TOKEN_RENEW_AGE: 15*60, // 15 mins - TOKEN_MAX_AGE: 30*86400, // 30 days - TOKEN_LENGTH: 24, // bytes - SESSION_ID_LENGTH: 12, - USERNAME_MAX_LENGTH: 128, - PASSWORD_MIN_LENGTH: 8, - PASSWORD_MAX_LENGTH: 512, // Avoid DDOS - RATE_LIMIT_MAX_LEVEL: 16, - RATE_LIMIT_MAX_WAITING: 512, - fingerprintIP: req => - //req.headers["cf-connecting-ip"] || - //req.headers["x-forwarded-for"] || - req.socket.remoteAddress, - }, +export const auth = deepFreeze({ + TOKEN_RENEW_AGE: 15*60, // 15 mins + TOKEN_MAX_AGE: 30*86400, // 30 days + TOKEN_LENGTH: 24, // bytes + SESSION_ID_LENGTH: 12, + USERNAME_MAX_LENGTH: 128, + PASSWORD_MIN_LENGTH: 8, + PASSWORD_MAX_LENGTH: 512, // Avoid DDOS + RATE_LIMIT_MAX_LEVEL: 16, + RATE_LIMIT_MAX_WAITING: 512, + fingerprintIP: req => + //req.headers["cf-connecting-ip"] || + //req.headers["x-forwarded-for"] || + req.socket.remoteAddress, }); + +export const NOTE_DIR = "./users"; |