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