Commit c07e4d11491305425595ca66e533bfc02f22beb6

Authored by José Maria Villac Pinheiro
1 parent dcc1476d

V. 0.7.1 - Added some comments and prepared for production to Heroku.

.vscode/settings.json 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +{
  2 +
  3 +}
0 4 \ No newline at end of file
... ...
bin/www
1   -#!/usr/bin/env node
  1 +#!/usr/bin/env node // to invoke node, in linux system, that is installed in a path accessed through the environment variable
2 2  
3 3 /**
4 4 * Module dependencies.
  5 + * Everything starts here
5 6 */
6 7  
7   -var app = require('../app');
  8 +var app = require('../app'); // call app.js that will call routes throught ../routes/index.js
8 9 var debug = require('debug')('pg-node:server');
9 10 var http = require('http');
10 11  
11   -// /**
12   -// * Production verification
13   -// */
14   -// var express = require("express");
15   -// if (process.env.NODE_ENV === 'production') {
16   -// // Express will serve up production assets
17   -// // like our main.js file, or main.css file!
18   -// app.use(express.static('../client/build'));
19   -
20   -// // Express will serve up the index.html file
21   -// // if it doesn't recognize the route
22   -// const path = require('path');
23   -// app.get('*', (req, res) => {
24   -// res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
25   -// });
26   -// }
  12 +/**
  13 + * Production version verification. It needs to build for React client.
  14 + */
  15 +var express = require("express");
  16 +if (process.env.NODE_ENV === 'production') {
  17 + // Express will serve up production assets
  18 + // like our main.js file or main.css file!
  19 + // this guarantees that expressjs will look
  20 + // for specific files in specific directories
  21 + app.use(express.static('../client/build')); // if get request comes in from some route or some file or for anything for my application and we do not understant, then look in some file from this directory to see if some file that matches up the request
  22 +
  23 + // Express will serve up the index.html file
  24 + // if it doesn't recognize the route.
  25 + // If something arrives from a route that we do not understand,
  26 + // look at the index.htm file in the client directory
  27 + const path = require('path');
  28 + app.get('*', (req, res) => {
  29 + res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
  30 + });
  31 +}
27 32  
28 33 /**
29 34 * Define port
30 35 */
31   -
32 36 var port = normalizePort(process.env.PORT || '5000');
33 37 app.set('port', port);
34 38  
... ...
client/package.json
1 1 {
2 2 "name": "client",
3   - "version": "0.7.0",
  3 + "version": "0.7.1",
4 4 "private": true,
5 5 "proxy": {
6 6 "/map": {
... ...
client/public/index.html
  1 +<!-- Html start page -->
1 2 <!DOCTYPE html>
2 3 <html lang="en">
3 4 <head>
4 5 <meta charset="utf-8">
5 6 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6 7 <meta name="theme-color" content="#000000">
7   - <!--
8   - manifest.json provides metadata used when your web app is added to the
9   - homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
10   - -->
11 8 <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
12 9 <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
13   - <!--
14   - Notice the use of %PUBLIC_URL% in the tags above.
15   - It will be replaced with the URL of the `public` folder during the build.
16   - Only files inside the `public` folder can be referenced from the HTML.
17   -
18   - Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
19   - work correctly both with client-side routing and a non-root public URL.
20   - Learn how to configure a non-root public URL by running `npm run build`.
21   - -->
22 10 <title>NEXUS</title>
23 11 </head>
24 12 <body>
... ... @@ -26,15 +14,5 @@
26 14 You need to enable JavaScript to run this app.
27 15 </noscript>
28 16 <div id="root"></div>
29   - <!--
30   - This HTML file is a template.
31   - If you open it directly in the browser, you will see an empty page.
32   -
33   - You can add webfonts, meta tags, or analytics to this file.
34   - The build step will place the bundled scripts into the <body> tag.
35   -
36   - To begin the development, run `npm start` or `yarn start`.
37   - To create a production bundle, use `npm run build` or `yarn build`.
38   - -->
39 17 </body>
40 18 </html>
... ...
client/public/manifest.json
1 1 {
2   - "short_name": "React App",
3   - "name": "Create React App Sample",
  2 + "short_name": "GeoSanWeb",
  3 + "name": "Map application for water companies",
4 4 "icons": [
5 5 {
6 6 "src": "favicon.ico",
... ...
client/src/index.js
  1 +/**
  2 + * @description JavaScript entry point - renders the React element App from App.js in the DOM supplied at the public/index.html container
  3 + * @author José Maria Villac Pinheiro
  4 + * @date 2018-07-19
  5 + */
1 6 import React from "react";
2 7 import ReactDOM from "react-dom";
3 8 import "./index.css";
... ...
package.json
1 1 {
2 2 "name": "GeoSanWeb",
3   - "version": "0.7.0",
  3 + "version": "0.7.1",
4 4 "description": "Map application for water companies",
5 5 "repository": "git@bitbucket.org:nexusbr/geosanweb.git",
6 6 "private": true,
... ... @@ -12,7 +12,8 @@
12 12 "start": "node ./bin/www",
13 13 "server": "nodemon ./bin/www",
14 14 "client": "npm run start --prefix client",
15   - "dev": "concurrently \"npm run server\" \"npm run client\""
  15 + "dev": "concurrently \"npm run server\" \"npm run client\"",
  16 + "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
16 17 },
17 18 "author": "José Maria Villac Pinheiro",
18 19 "dependencies": {
... ...