From a4c8e09632bd1bf1c31264a121a99ba1db1024e9 Mon Sep 17 00:00:00 2001 From: johtela Date: Wed, 6 Nov 2024 09:41:31 +0200 Subject: [PATCH] Remove .env file support --- src/backend.ts | 30 ------------------------------ src/server.ts | 1 - 2 files changed, 31 deletions(-) diff --git a/src/backend.ts b/src/backend.ts index d32f5d5..806d0a9 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -10,11 +10,7 @@ * [Express.js applications]: https://expressjs.com/en/5x/api.html#app */ //#region -c backend imports -import * as path from 'path' -import * as fs from 'fs' import * as exp from 'express' -import * as cfg from './config' -import * as log from './logging' //#endregion /** * ## Express Middleware @@ -56,30 +52,4 @@ export function invalidateBackend() { app = undefined delete require.cache[bundle] } -} -/** - * ## Read `.env` file - * - * If the root folder contains a file called `.env` load environment variables - * from it. - */ -const varDefRE = /^([A-Za-z]\w*)\s*\=\s*(.+)$/ - -export function loadEnvFile() { - let envpath = path.resolve(cfg.getOptions().baseDir, ".env") - if (fs.existsSync(envpath)) { - let content = fs.readFileSync(envpath, 'utf-8').split(/\r?\n/) - for (let i = 0; i < content.length; ++i) { - let line = content[i].trim() - if (line && !line.startsWith("#")) { - let match = line.match(varDefRE) - if (match) - process.env[match[1]] = match[2] - else { - log.warn("Invalid line skipped in .env file:\n" + line) - log.info("Correct format is =\n") - } - } - } - } } \ No newline at end of file diff --git a/src/server.ts b/src/server.ts index e714bf8..866c76b 100644 --- a/src/server.ts +++ b/src/server.ts @@ -63,7 +63,6 @@ export function start(opts: cfg.Options) { }) } app.use(exp.static(opts.outDir)) - bak.loadEnvFile() app.use(bak.backend) app.get('/litscript', notifyHandler) let { host, port } = opts.serveOptions