mirror of
https://github.com/rjNemo/MERN_sample_app
synced 2026-06-12 03:26:40 +00:00
prepares for deployment on heroku
This commit is contained in:
parent
268314537a
commit
3f75445d0d
6 changed files with 20 additions and 37 deletions
|
|
@ -5,39 +5,13 @@
|
||||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta
|
<meta name="description" content="Doo & Loo's shopping list" />
|
||||||
name="description"
|
|
||||||
content="Web site created using create-react-app"
|
|
||||||
/>
|
|
||||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||||
<!--
|
|
||||||
manifest.json provides metadata used when your web app is installed on a
|
|
||||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
||||||
-->
|
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
<!--
|
<title>Shop'it</title>
|
||||||
Notice the use of %PUBLIC_URL% in the tags above.
|
|
||||||
It will be replaced with the URL of the `public` folder during the build.
|
|
||||||
Only files inside the `public` folder can be referenced from the HTML.
|
|
||||||
|
|
||||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
||||||
work correctly both with client-side routing and a non-root public URL.
|
|
||||||
Learn how to configure a non-root public URL by running `npm run build`.
|
|
||||||
-->
|
|
||||||
<title>React Redux App</title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<!--
|
|
||||||
This HTML file is a template.
|
|
||||||
If you open it directly in the browser, you will see an empty page.
|
|
||||||
|
|
||||||
You can add webfonts, meta tags, or analytics to this file.
|
|
||||||
The build step will place the bundled scripts into the <body> tag.
|
|
||||||
|
|
||||||
To begin the development, run `npm start` or `yarn start`.
|
|
||||||
To create a production bundle, use `npm run build` or `yarn build`.
|
|
||||||
-->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"short_name": "React App",
|
"short_name": "Shop'it",
|
||||||
"name": "Create React App Sample",
|
"name": "Shop'it | Doo & Loo's shopping list",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "favicon.ico",
|
"src": "favicon.ico",
|
||||||
|
|
@ -22,4 +22,4 @@
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"theme_color": "#000000",
|
"theme_color": "#000000",
|
||||||
"background_color": "#ffffff"
|
"background_color": "#ffffff"
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Modal,
|
Modal,
|
||||||
|
|
@ -10,7 +11,6 @@ import {
|
||||||
Input,
|
Input,
|
||||||
} from "reactstrap";
|
} from "reactstrap";
|
||||||
import { addItemAsync } from "../../store/itemSlice";
|
import { addItemAsync } from "../../store/itemSlice";
|
||||||
import { useDispatch } from "react-redux";
|
|
||||||
|
|
||||||
const useStyles = () => ({
|
const useStyles = () => ({
|
||||||
button: {
|
button: {
|
||||||
|
|
@ -46,7 +46,7 @@ export default function ItemModal() {
|
||||||
<Label for="item">Add an Item</Label>
|
<Label for="item">Add an Item</Label>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
name="name"
|
// name="name"
|
||||||
id="item"
|
id="item"
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,8 @@ export const itemSlice = createSlice({
|
||||||
...state,
|
...state,
|
||||||
items: [action.payload, ...state.items],
|
items: [action.payload, ...state.items],
|
||||||
}),
|
}),
|
||||||
deleteItem: (state, action) => ({
|
deleteItem: (state, action) =>
|
||||||
...state,
|
state.items.filter((i) => i._id !== action.payload),
|
||||||
items: state.items.filter((i) => i._id !== action.payload),
|
|
||||||
}),
|
|
||||||
setItemsLoading: (state) => ({ ...state, loading: true }),
|
setItemsLoading: (state) => ({ ...state, loading: true }),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
"client": "npm start --prefix client",
|
"client": "npm start --prefix client",
|
||||||
"client-install": "npm install --prefix client",
|
"client-install": "npm install --prefix client",
|
||||||
"dev": "concurrently \"npm run server\" \"npm run client\"",
|
"dev": "concurrently \"npm run server\" \"npm run client\"",
|
||||||
|
"build": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "npm run test -- --watch"
|
"test:watch": "npm run test -- --watch"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
10
server.js
10
server.js
|
|
@ -1,5 +1,6 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
|
import path from "path";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { MONGO_URI } from "./config/keys.js";
|
import { MONGO_URI } from "./config/keys.js";
|
||||||
import items from "./routes/api/items.js";
|
import items from "./routes/api/items.js";
|
||||||
|
|
@ -22,6 +23,15 @@ app.use(express.json());
|
||||||
// Register routes
|
// Register routes
|
||||||
app.use("/api/items/", items);
|
app.use("/api/items/", items);
|
||||||
|
|
||||||
|
// Serve static assets in Production
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === "PRODUCTION") {
|
||||||
|
app.use(express.static("client/build"));
|
||||||
|
app.get("*", (req, res) => {
|
||||||
|
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Starts server
|
// Starts server
|
||||||
app.listen(PORT, () =>
|
app.listen(PORT, () =>
|
||||||
console.log(
|
console.log(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue