Skip to content

Commit

Permalink
Replace config with .env
Browse files Browse the repository at this point in the history
  • Loading branch information
poeti8 committed May 29, 2019
1 parent 48a8b9e commit 8b594a0
Show file tree
Hide file tree
Showing 23 changed files with 2,034 additions and 3,875 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
TEST=test
55 changes: 55 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# App port to run on
PORT=3000

# The domain that this website is on
DEFAULT_DOMAIN="kutt.it"

# Neo4j database credential details
DB_URI="bolt://localhost"
DB_USERNAME=
DB_PASSWORD=

# Redis host and port
REDIS_DISABLED=false
REDIS_HOST="127.0.0.1"
REDIS_PORT=6379
REDIS_PASSWORD=

# The daily limit for each user
USER_LIMIT_PER_DAY=50

# A passphrase to encrypt JWT. Use a long and secure key.
JWT_SECRET=securekey

# Admin emails so they can access admin actions on settings page
# Comma seperated
ADMIN_EMAILS=

# Invisible reCaptcha secret key
# Create one in https://www.google.com/recaptcha/intro/
RECAPTCHA_SITE_KEY=6LdVeUYUAAAAAAPX2XAH71soH8xVPrMjpIR3pE8f
RECAPTCHA_SECRET_KEY=

# Google Cloud API to prevent from users from submitting malware URLs.
# Get it from https://developers.google.com/safe-browsing/v4/get-started
GOOGLE_SAFE_BROWSING_KEY=

# Google Analytics tracking ID for universal analytics.
# Example: UA-XXXX-XX
GOOGLE_ANALYTICS=

# Your email host details to use to send verification emails.
# More info on http://nodemailer.com/
# Mail from example "Kutt <support@kutt.it>". Leave empty to use MAIL_USER
MAIL_HOST=
MAIL_PORT=587
MAIL_SECURE=
MAIL_USER=
MAIL_FROM=
MAIL_PASSWORD=

# The email address that will receive submitted reports.
REPORT_MAIL=

# Support email to show on the app
CONTACT_EMAIL=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.vscode/
client/.next/
node_modules/
Expand Down
3 changes: 1 addition & 2 deletions client/components/BodyWrapper/BodyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Header from '../Header';
import PageLoading from '../PageLoading';
import { renewAuthUser, hidePageLoading } from '../../actions';
import { initGA, logPageView } from '../../helpers/analytics';
import { GOOGLE_ANALYTICS_ID } from '../../config';

const Wrapper = styled.div`
position: relative;
Expand Down Expand Up @@ -43,7 +42,7 @@ const ContentWrapper = styled.div`

class BodyWrapper extends React.Component {
componentDidMount() {
if (GOOGLE_ANALYTICS_ID) {
if (process.env.GOOGLE_ANALYTICS_ID) {
if (!window.GA_INITIALIZED) {
initGA();
window.GA_INITIALIZED = true;
Expand Down
5 changes: 2 additions & 3 deletions client/components/Footer/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { connect } from 'react-redux';
import styled from 'styled-components';
import ReCaptcha from './ReCaptcha';
import showRecaptcha from '../../helpers/recaptcha';
import config from '../../config';

const Wrapper = styled.footer`
width: 100%;
Expand Down Expand Up @@ -61,10 +60,10 @@ class Footer extends Component {
<a href="/report" title="Report abuse">
Report Abuse
</a>
{config.CONTACT_EMAIL && (
{process.env.CONTACT_EMAIL && (
<Fragment>
{' | '}
<a href={`mailto:${config.CONTACT_EMAIL}`} title="Contact us">
<a href={`mailto:${process.env.CONTACT_EMAIL}`} title="Contact us">
Contact us
</a>
</Fragment>
Expand Down
3 changes: 1 addition & 2 deletions client/components/Footer/ReCaptcha.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import styled from 'styled-components';
import config from '../../config';

const Recaptcha = styled.div`
display: flex;
Expand All @@ -11,7 +10,7 @@ const ReCaptcha = () => (
<Recaptcha
id="g-recaptcha"
className="g-recaptcha"
data-sitekey={config.RECAPTCHA_SITE_KEY}
data-sitekey={process.env.RECAPTCHA_SITE_KEY}
data-callback="recaptchaCallback"
data-size="invisible"
data-badge="inline"
Expand Down
16 changes: 0 additions & 16 deletions client/config.example.js

This file was deleted.

3 changes: 1 addition & 2 deletions client/helpers/analytics.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import ReactGA from 'react-ga';
import { GOOGLE_ANALYTICS_ID } from '../config';

export const initGA = () => {
ReactGA.initialize(GOOGLE_ANALYTICS_ID);
ReactGA.initialize(process.env.GOOGLE_ANALYTICS_ID);
};

export const logPageView = () => {
Expand Down
3 changes: 1 addition & 2 deletions client/pages/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import styled from 'styled-components';
import axios from 'axios';
import BodyWrapper from '../components/BodyWrapper';
import { authUser } from '../actions';
import { REPORT_EMAIL } from '../config';
import TextInput from '../components/TextInput';
import Button from '../components/Button';

Expand Down Expand Up @@ -98,7 +97,7 @@ class ReportPage extends Component {
Report abuses, malware and phishing links to the below email address or use the form. We
will take actions shortly.
</p>
<p>{REPORT_EMAIL}</p>
<p>{process.env.REPORT_EMAIL}</p>
<p>
<b>URL containting malware/scam:</b>
</p>
Expand Down
10 changes: 10 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { parsed: localEnv } = require('dotenv').config();
const webpack = require('webpack'); // eslint-disable-line

module.exports = {
webpack(config) {
config.plugins.push(new webpack.EnvironmentPlugin(localEnv));

return config;
},
};
Loading

0 comments on commit 8b594a0

Please sign in to comment.