mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-20 13:34:30 +01:00
chore: fix envs and add base path
This commit is contained in:
parent
115266b264
commit
00c78513ec
10 changed files with 61 additions and 31 deletions
|
@ -10,4 +10,6 @@
|
|||
.env
|
||||
.vscode
|
||||
.storybook
|
||||
CHANGELOG.md
|
||||
CHANGELOG.md
|
||||
.elasticbeanstalk/*
|
||||
.ebextensions/*
|
|
@ -1,13 +1,23 @@
|
|||
const { parsed: localEnv } = require('dotenv').config();
|
||||
const webpack = require('webpack');
|
||||
module.exports = {
|
||||
webpack: config => {
|
||||
config.plugins.push(new webpack.EnvironmentPlugin(localEnv));
|
||||
return config;
|
||||
},
|
||||
};
|
||||
|
||||
const dotEnvResult = require('dotenv').config();
|
||||
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
||||
enabled: process.env.ANALYZE === 'true',
|
||||
});
|
||||
module.exports = withBundleAnalyzer({});
|
||||
|
||||
if (dotEnvResult.error) {
|
||||
throw dotEnvResult.error;
|
||||
}
|
||||
|
||||
module.exports = withBundleAnalyzer({
|
||||
poweredByHeader: false,
|
||||
assetPrefix: process.env.BASE_PATH || '',
|
||||
serverRuntimeConfig: {
|
||||
nodeEnv: process.env.NODE_ENV || 'development',
|
||||
logLevel: process.env.LOG_LEVEL || 'silly',
|
||||
hodlKey: process.env.HODL_KEY || '',
|
||||
},
|
||||
publicRuntimeConfig: {
|
||||
nodeEnv: process.env.NODE_ENV || 'development',
|
||||
basePath: process.env.BASE_PATH || '',
|
||||
npmVersion: process.env.npm_package_version || '0.0.0',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { authenticatedLndGrpc } from 'ln-service';
|
||||
import { envConfig } from '../utils/envConfig';
|
||||
import getConfig from 'next/config';
|
||||
|
||||
const { serverRuntimeConfig } = getConfig();
|
||||
const { nodeEnv } = serverRuntimeConfig;
|
||||
|
||||
export const getIp = (req: any) => {
|
||||
if (!req || !req.headers) {
|
||||
|
@ -9,7 +12,7 @@ export const getIp = (req: any) => {
|
|||
const before = forwarded
|
||||
? forwarded.split(/, /)[0]
|
||||
: req.connection.remoteAddress;
|
||||
const ip = envConfig.env === 'development' ? '1.2.3.4' : before;
|
||||
const ip = nodeEnv === 'development' ? '1.2.3.4' : before;
|
||||
return ip;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { createLogger, format, transports } from 'winston';
|
||||
import getConfig from 'next/config';
|
||||
import path from 'path';
|
||||
import { envConfig } from '../utils/envConfig';
|
||||
|
||||
const { serverRuntimeConfig } = getConfig();
|
||||
const { logLevel, nodeEnv } = serverRuntimeConfig;
|
||||
|
||||
const combinedFormat =
|
||||
envConfig.env === 'development'
|
||||
nodeEnv === 'development'
|
||||
? format.combine(
|
||||
format.label({
|
||||
label: path.basename(
|
||||
|
@ -33,7 +36,7 @@ const combinedFormat =
|
|||
);
|
||||
|
||||
export const logger = createLogger({
|
||||
level: envConfig.logLevel,
|
||||
level: logLevel,
|
||||
format: combinedFormat,
|
||||
transports: [new transports.Console()],
|
||||
});
|
||||
|
|
|
@ -4,7 +4,10 @@ import { requestLimiter } from '../../../helpers/rateLimiter';
|
|||
import { logger } from '../../../helpers/logger';
|
||||
import { appUrls } from '../../../utils/appUrls';
|
||||
import { HodlCountryType } from '../../types/HodlType';
|
||||
import { envConfig } from '../../../utils/envConfig';
|
||||
import getConfig from 'next/config';
|
||||
|
||||
const { serverRuntimeConfig } = getConfig();
|
||||
const { hodlKey } = serverRuntimeConfig;
|
||||
|
||||
export const getCountries = {
|
||||
type: new GraphQLList(HodlCountryType),
|
||||
|
@ -13,7 +16,7 @@ export const getCountries = {
|
|||
await requestLimiter(context.ip, 'getCountries');
|
||||
|
||||
const headers = {
|
||||
Authorization: `Bearer ${envConfig.hodlKey}`,
|
||||
Authorization: `Bearer ${hodlKey}`,
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,10 @@ import { requestLimiter } from '../../../helpers/rateLimiter';
|
|||
import { logger } from '../../../helpers/logger';
|
||||
import { appUrls } from '../../../utils/appUrls';
|
||||
import { HodlCurrencyType } from '../../types/HodlType';
|
||||
import { envConfig } from '../../../utils/envConfig';
|
||||
import getConfig from 'next/config';
|
||||
|
||||
const { serverRuntimeConfig } = getConfig();
|
||||
const { hodlKey } = serverRuntimeConfig;
|
||||
|
||||
export const getCurrencies = {
|
||||
type: new GraphQLList(HodlCurrencyType),
|
||||
|
@ -13,7 +16,7 @@ export const getCurrencies = {
|
|||
await requestLimiter(context.ip, 'getCurrencies');
|
||||
|
||||
const headers = {
|
||||
Authorization: `Bearer ${envConfig.hodlKey}`,
|
||||
Authorization: `Bearer ${hodlKey}`,
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
export const envConfig = {
|
||||
env: process.env.NODE_ENV || 'development',
|
||||
logLevel: process.env.LOG_LEVEL || 'silly',
|
||||
hodlKey: process.env.HODL_KEY,
|
||||
};
|
|
@ -6,6 +6,7 @@ import { Input } from '../../input/Input';
|
|||
import { Line, CheckboxText } from '../Auth.styled';
|
||||
import { LoadingBar } from '../../loadingBar/LoadingBar';
|
||||
import { Checkbox } from '../../checkbox/Checkbox';
|
||||
import getConfig from 'next/config';
|
||||
|
||||
interface PasswordProps {
|
||||
isPass?: string;
|
||||
|
@ -14,6 +15,9 @@ interface PasswordProps {
|
|||
loading: boolean;
|
||||
}
|
||||
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
const { nodeEnv } = publicRuntimeConfig;
|
||||
|
||||
const PasswordInput = ({
|
||||
isPass = '',
|
||||
setPass,
|
||||
|
@ -22,7 +26,7 @@ const PasswordInput = ({
|
|||
}: PasswordProps) => {
|
||||
const [checked, setChecked] = useState(false);
|
||||
const strength = (100 * Math.min(zxcvbn(isPass).guesses_log10, 40)) / 40;
|
||||
const needed = process.env.NODE_ENV !== 'development' ? 1 : checked ? 10 : 20;
|
||||
const needed = nodeEnv === 'development' ? 1 : checked ? 10 : 20;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -3,6 +3,7 @@ import styled, { css } from 'styled-components';
|
|||
import { textColor, linkHighlight } from '../../styles/Themes';
|
||||
import { ThemeSet } from 'styled-theming';
|
||||
import RouterLink from 'next/link';
|
||||
import getConfig from 'next/config';
|
||||
|
||||
interface StyledProps {
|
||||
fontColor?: string | ThemeSet;
|
||||
|
@ -11,7 +12,7 @@ interface StyledProps {
|
|||
fullWidth?: boolean;
|
||||
}
|
||||
|
||||
const StyledALink = styled.a`
|
||||
const StyledLink = styled.a`
|
||||
cursor: pointer;
|
||||
color: ${({ fontColor, inheritColor }: StyledProps) =>
|
||||
inheritColor ? 'inherit' : fontColor ?? textColor};
|
||||
|
@ -49,6 +50,9 @@ interface LinkProps {
|
|||
noStyling?: boolean;
|
||||
}
|
||||
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
const { basePath } = publicRuntimeConfig;
|
||||
|
||||
export const Link = ({
|
||||
children,
|
||||
href,
|
||||
|
@ -63,7 +67,7 @@ export const Link = ({
|
|||
|
||||
if (!href && !to) return null;
|
||||
|
||||
const CorrectLink = noStyling ? NoStyling : StyledALink;
|
||||
const CorrectLink = noStyling ? NoStyling : StyledLink;
|
||||
|
||||
if (href) {
|
||||
return (
|
||||
|
@ -74,9 +78,8 @@ export const Link = ({
|
|||
}
|
||||
|
||||
return (
|
||||
<RouterLink href={to}>
|
||||
<RouterLink href={`${basePath}${to}`}>
|
||||
<CorrectLink {...props}>{children}</CorrectLink>
|
||||
</RouterLink>
|
||||
);
|
||||
// }
|
||||
};
|
||||
|
|
|
@ -13,6 +13,7 @@ import { useAccount } from '../../context/AccountContext';
|
|||
import RouterLink from 'next/link';
|
||||
import { HomeButton } from '../../views/homepage/HomePage.styled';
|
||||
import { Zap } from '../../components/generic/Icons';
|
||||
import getConfig from 'next/config';
|
||||
|
||||
const FooterStyle = styled.div`
|
||||
padding: 40px 0;
|
||||
|
@ -91,6 +92,9 @@ const Version = styled.div`
|
|||
margin-left: 8px;
|
||||
`;
|
||||
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
const { npmVersion } = publicRuntimeConfig;
|
||||
|
||||
export const Footer = () => {
|
||||
const { loggedIn } = useAccount();
|
||||
return (
|
||||
|
@ -101,7 +105,7 @@ export const Footer = () => {
|
|||
<Link to={'/'}>
|
||||
<Title>ThunderHub</Title>
|
||||
</Link>
|
||||
<Version>{'0.3.0'}</Version>
|
||||
<Version>{npmVersion}</Version>
|
||||
</Line>
|
||||
<SideText>
|
||||
Open-source lightning node manager to control and monitor your LND
|
||||
|
|
Loading…
Add table
Reference in a new issue