forked from nm3clol/nm3clol-express-app
feat: Trim slashes on all .env config URLs, SITE_URL, SOLR_DOCS_URL, TIKA_URL, etc.
This commit is contained in:
parent
21ce16d3e0
commit
c2e4899d3c
|
@ -187,6 +187,9 @@ import dotenv from 'dotenv';
|
||||||
import dotenvExpand from 'dotenv-expand';
|
import dotenvExpand from 'dotenv-expand';
|
||||||
import process from 'process';
|
import process from 'process';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
export const trimSlashes = (dirPath: string) => {
|
||||||
|
return dirPath.replace(/^[\/\\]|[\/\\]$/g, '');
|
||||||
|
};
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
@ -212,7 +215,7 @@ export const getAppHttpUrl = () => {
|
||||||
export const getSiteName = () => env.SITE_NAME||"(dev) No Moss 3 Carbo Landfill Online Localhost";
|
export const getSiteName = () => env.SITE_NAME||"(dev) No Moss 3 Carbo Landfill Online Localhost";
|
||||||
export const getSiteWelcomeMessage = () => env.SITE_WELCOME_MESSAGE||"Devel' It Up, Developer!";
|
export const getSiteWelcomeMessage = () => env.SITE_WELCOME_MESSAGE||"Devel' It Up, Developer!";
|
||||||
export const getSiteHost = () => env.SITE_HOST||"localhost";
|
export const getSiteHost = () => env.SITE_HOST||"localhost";
|
||||||
export const getSiteUrl = () => env.SITE_URL||getAppHttpUrl();
|
export const getSiteUrl = () => trimSlashes(env.SITE_URL||getAppHttpUrl());
|
||||||
|
|
||||||
// Note the difference: PUBLIC_PATH is expected to be one level above the project folder and PAGES_PATH, STATIC_PATH, and VIEWS_PATH are all copied from src/ to dist/.
|
// Note the difference: PUBLIC_PATH is expected to be one level above the project folder and PAGES_PATH, STATIC_PATH, and VIEWS_PATH are all copied from src/ to dist/.
|
||||||
export const getPublicPath = () => path.join(__dirname, '..', '..', (env.PUBLIC_PATH||path.join('..', 'nm3clol-public')).replaceAll('\\', path.sep).replaceAll('/', path.sep));
|
export const getPublicPath = () => path.join(__dirname, '..', '..', (env.PUBLIC_PATH||path.join('..', 'nm3clol-public')).replaceAll('\\', path.sep).replaceAll('/', path.sep));
|
||||||
|
@ -223,16 +226,16 @@ export const getViewsPath = () => path.join(__dirname, '..', '..', 'dist', 'view
|
||||||
export const getSolrDocsHost = () => env.SOLR_DOCS_HOST||'solr';
|
export const getSolrDocsHost = () => env.SOLR_DOCS_HOST||'solr';
|
||||||
export const getSolrDocsPort = () => parseInt(env.SOLR_DOCS_PORT||'8983');
|
export const getSolrDocsPort = () => parseInt(env.SOLR_DOCS_PORT||'8983');
|
||||||
export const getSolrDocsCore = () => env.SOLR_DOCS_CORE||'nm3clol_core';
|
export const getSolrDocsCore = () => env.SOLR_DOCS_CORE||'nm3clol_core';
|
||||||
export const getSolrDocsUrl = () => env.SOLR_DOCS_URL||`http://${getSolrDocsHost()}:${getSolrDocsPort()}/solr/${getSolrDocsCore()}`;
|
export const getSolrDocsUrl = () => trimSlashes(env.SOLR_DOCS_URL||`http://${getSolrDocsHost()}:${getSolrDocsPort()}/solr/${getSolrDocsCore()}`);
|
||||||
|
|
||||||
export const getSolrLawHost = () => env.SOLR_LAW_HOST||getSolrDocsHost();
|
export const getSolrLawHost = () => env.SOLR_LAW_HOST||getSolrDocsHost();
|
||||||
export const getSolrLawPort = () => env.SOLR_LAW_PORT ? parseInt(env.SOLR_LAW_PORT) : getSolrDocsPort();
|
export const getSolrLawPort = () => env.SOLR_LAW_PORT ? parseInt(env.SOLR_LAW_PORT) : getSolrDocsPort();
|
||||||
export const getSolrLawCore = () => env.SOLR_LAW_CORE||'vacode_core';
|
export const getSolrLawCore = () => env.SOLR_LAW_CORE||'vacode_core';
|
||||||
export const getSolrLawUrl = () => env.SOLR_LAW_URL||`http://${getSolrLawHost()}:${getSolrLawPort()}/solr/${getSolrLawCore()}`;
|
export const getSolrLawUrl = () => trimSlashes(env.SOLR_LAW_URL||`http://${getSolrLawHost()}:${getSolrLawPort()}/solr/${getSolrLawCore()}`);
|
||||||
|
|
||||||
export const getTikaHost = () => env.TIKA_HOST||'tika';
|
export const getTikaHost = () => env.TIKA_HOST||'tika';
|
||||||
export const getTikaPort = () => parseInt(env.TIKA_PORT||'9998');
|
export const getTikaPort = () => parseInt(env.TIKA_PORT||'9998');
|
||||||
export const getTikaUrl = () => env.TIKA_URL||`http://${getTikaHost()}:${getTikaPort()}`;
|
export const getTikaUrl = () => trimSlashes(env.TIKA_URL||`http://${getTikaHost()}:${getTikaPort()}`);
|
||||||
|
|
||||||
export const config: Config = {
|
export const config: Config = {
|
||||||
appHttpHost: getAppHttpHost(),
|
appHttpHost: getAppHttpHost(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user