Skip to content

Commit

Permalink
Add in webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
boczeratul committed Apr 8, 2019
1 parent a5a621d commit 180942e
Show file tree
Hide file tree
Showing 98 changed files with 8,470 additions and 10,698 deletions.
53 changes: 53 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"presets": [
["env", {
"modules": false,
"useBuiltIn": true,
"targets": {
"browsers": [
"> 1%",
"last 2 versions",
"not ie <= 11",
"ios 9",
"not ie_mob 10",
"not and_uc <= 11.4",
"not bb < 10",
"not op_mob <= 12",
"not Android < 4.4"
]
}
}],
"react",
"stage-0",
"flow"
],
"env": {
"production": {
"only": [
"app"
],
"plugins": [
"transform-react-remove-prop-types",
"transform-react-constant-elements",
"transform-react-inline-elements"
]
},
"test": {
"plugins": [
"transform-es2015-modules-commonjs",
"dynamic-import-node"
]
}
},
"plugins": [
["react-loadable/babel", {
"webpack": true
}],
["module-resolver", {
"alias": {
"@": "./app"
}
}],
"polished"
]
}
3 changes: 3 additions & 0 deletions app/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.babelrc"
}
52 changes: 52 additions & 0 deletions app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<ifModule mod_rewrite.c>


#######################################################################
# GENERAL #
#######################################################################

# Make apache follow sym links to files
Options +FollowSymLinks
# If somebody opens a folder, hide all files from the resulting folder list
IndexIgnore */*


#######################################################################
# REWRITING #
#######################################################################

# Enable rewriting
RewriteEngine On

# If its not HTTPS
RewriteCond %{HTTPS} off

# Comment out the RewriteCond above, and uncomment the RewriteCond below if you're using a load balancer (e.g. CloudFlare) for SSL
# RewriteCond %{HTTP:X-Forwarded-Proto} !https

# Redirect to the same URL with https://, ignoring all further rules if this one is in effect
RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R,L]

# If we get to here, it means we are on https://

# If the file with the specified name in the browser doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f

# and the directory with the specified name in the browser doesn't exist
RewriteCond %{REQUEST_FILENAME} !-d

# and we are not opening the root already (otherwise we get a redirect loop)
RewriteCond %{REQUEST_FILENAME} !\/$

# Rewrite all requests to the root
RewriteRule ^(.*) /

</ifModule>

<IfModule mod_headers.c>
# Do not cache sw.js, required for offline-first updates.
<FilesMatch "sw\.js$">
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
</IfModule>
112 changes: 112 additions & 0 deletions app/.nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
##
# Put this file in /etc/nginx/conf.d folder and make sure
# you have a line 'include /etc/nginx/conf.d/*.conf;'
# in your main nginx configuration file
##

##
# Redirect to the same URL with https://
##

server {

listen 80;

# Type your domain name below
server_name example.com;

return 301 https://$server_name$request_uri;

}

##
# HTTPS configurations
##

server {

listen 443 ssl;

# Type your domain name below
server_name example.com;

# Configure the Certificate and Key you got from your CA (e.g. Lets Encrypt)
ssl_certificate /path/to/certificate.crt;
ssl_certificate_key /path/to/server.key;

ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;

# Only use TLS v1.2 as Transport Security Protocol
ssl_protocols TLSv1.2;

# Only use ciphersuites that are considered modern and secure by Mozilla
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';

# Do not let attackers downgrade the ciphersuites in Client Hello
# Always use server-side offered ciphersuites
ssl_prefer_server_ciphers on;

# HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
add_header Strict-Transport-Security max-age=15768000;

# Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
# Uncomment if you want to use your own Diffie-Hellman parameter, which can be generated with: openssl ecparam -genkey -out dhparam.pem -name prime256v1
# See https://wiki.mozilla.org/Security/Server_Side_TLS#DHE_handshake_and_dhparam
# ssl_dhparam /path/to/dhparam.pem;


## OCSP Configuration START
# If you want to provide OCSP Stapling, you can uncomment the following lines
# See https://www.digitalocean.com/community/tutorials/how-to-configure-ocsp-stapling-on-apache-and-nginx for more infos about OCSP and its use case
# fetch OCSP records from URL in ssl_certificate and cache them

#ssl_stapling on;
#ssl_stapling_verify on;

# verify chain of trust of OCSP response using Root CA and Intermediate certs (you will get this file from your CA)
#ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates;

## OCSP Configuration END

# To let nginx use its own DNS Resolver
# resolver <IP DNS resolver>;


# Always serve index.html for any request
location / {
# Set path
root /var/www/;
try_files $uri /index.html;
}

# Do not cache sw.js, required for offline-first updates.
location /sw.js {
add_header Cache-Control "no-cache";
proxy_cache_bypass $http_pragma;
proxy_cache_revalidate on;
expires off;
access_log off;
}

##
# If you want to use Node/Rails/etc. API server
# on the same port (443) config Nginx as a reverse proxy.
# For security reasons use a firewall like ufw in Ubuntu
# and deny port 3000/tcp.
##

# location /api/ {
#
# proxy_pass http://localhost:3000;
# proxy_http_version 1.1;
# proxy_set_header X-Forwarded-Proto https;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection 'upgrade';
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
#
# }

}
26 changes: 0 additions & 26 deletions app/README.md

This file was deleted.

28 changes: 28 additions & 0 deletions app/__tests__/i18n.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { formatTranslationMessages } from '../i18n';

jest.mock('../translations/en.json', () => ({
message1: 'default message',
message2: 'default message 2',
}));

const esTranslationMessages = {
message1: 'mensaje predeterminado',
message2: '',
};

describe('formatTranslationMessages', () => {
it('should build only defaults when DEFAULT_LOCALE', () => {
const result = formatTranslationMessages('en', { a: 'a' });

expect(result).toEqual({ a: 'a' });
});

it('should combine default locale and current locale when not DEFAULT_LOCALE', () => {
const result = formatTranslationMessages('', esTranslationMessages);

expect(result).toEqual({
message1: 'mensaje predeterminado',
message2: 'default message 2',
});
});
});
24 changes: 24 additions & 0 deletions app/__tests__/reducers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Test route reducer
*/

import { fromJS } from 'immutable';
import { LOCATION_CHANGE } from 'react-router-redux';
import { routeReducer } from '../reducers';

describe('route reducer', () => {
it('should return the initial state', () => {
const initialState = { foo: 'bar' };
expect(routeReducer(initialState, {})).toEqual(initialState);
});

it('should handle the location_change action correctly', () => {
const state = fromJS({ location: 'somewhere' });
const payload = 'elsewhere';
const action = { type: LOCATION_CHANGE, payload };

const expectedState = { location: payload };
const resultState = routeReducer(state, action).toJS();
expect(resultState).toEqual(expectedState);
});
});
43 changes: 43 additions & 0 deletions app/__tests__/store.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Test store addons
*/

import { browserHistory } from 'react-router-dom';
import configureStore from '../configureStore';

describe('configureStore', () => {
let store;

beforeAll(() => {
store = configureStore({}, browserHistory);
});

describe('injectedReducers', () => {
it('should contain an object for reducers', () => {
expect(typeof store.injectedReducers).toBe('object');
});
});

describe('injectedEpics', () => {
it('should contain an object for epics', () => {
expect(typeof store.injectedEpics).toBe('object');
});
});

describe('addEpic', () => {
it('should contain a hook for async epic injection', () => {
expect(typeof store.addEpic).toBe('function');
});
});
});

describe('configureStore params', () => {
it('should call window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__', () => {
/* eslint-disable no-underscore-dangle */
const compose = jest.fn();
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ = () => compose;
configureStore(undefined, browserHistory);
expect(compose).toHaveBeenCalled();
/* eslint-enable */
});
});
Loading

0 comments on commit 180942e

Please sign in to comment.