Skip to content

Commit

Permalink
heroku config
Browse files Browse the repository at this point in the history
  • Loading branch information
CampbellOleson committed Aug 20, 2019
1 parent ee26c72 commit 52b4ba1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/frontend/node_modules
/node_modules
/config/keys.js
/config/keys.js
/config/keys_dev.js
10 changes: 9 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const mongoose = require("mongoose");
const path = require("path");
const express = require("express"); // the actual
const app = express();
const db = require("./config/keys").mongoURI;
Expand All @@ -9,10 +10,17 @@ const surfSpots = require("./routes/api/surf_spots");
// const seeds = require("./seeds");
// const SurfSpot = require("./models/SurfSpot");

if (process.env.NODE_ENV === 'production') {
app.use(express.static('frontend/build'));
app.get('/', (req, res) => {
res.sendFile(path.resolve(__dirname, 'frontend', 'build', 'index.html'));
})
}

mongoose
.connect(db, { useNewUrlParser: true })
.then(() => console.log("Connected to MongoDB successfully"))
.catch(err => console.log(err))
.catch(err => console.log(err));
// .then(SurfSpot.collection.insert(seeds))
// .then(console.log("Succesfully seeded MongoDB"));

Expand Down
4 changes: 4 additions & 0 deletions config/keys_prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
mongoURI: process.env.MONGO_URI,
secretOrKey: process.env.SECRET_OR_KEY
}
1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
},
"proxy": "http://localhost:5000",
"scripts": {
"postinstall": "webpack --mode=production",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"debug": "node --inspect app.js",
"frontend-install": "npm install --prefix frontend",
"frontend": "npm start --prefix frontend",
"dev": "concurrently \"npm run server\" \"npm run frontend\""
"dev": "concurrently \"npm run server\" \"npm run frontend\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && npm run build --prefix frontend"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 52b4ba1

Please sign in to comment.