silphius/environment.server.js
2024-11-04 12:39:06 -06:00

22 lines
578 B
JavaScript

export default function environment() {
const {
HTTPS_CERT,
HTTPS_KEY,
MKCERT,
NODE_ENV,
PORT = 3100,
} = process.env;
const useMkcert = !!MKCERT;
const cacheDirectory = `${import.meta.dirname}/node_modules/.cache`;
const httpsCert = HTTPS_CERT || (useMkcert && `${cacheDirectory}/localhost.pem`);
const httpsKey = HTTPS_KEY || (useMkcert && `${cacheDirectory}/localhost-key.pem`);
return {
httpsCert,
httpsKey,
isInsecure: !httpsCert || !httpsKey,
isProduction: NODE_ENV === 'production',
port: PORT,
useMkcert,
};
}