Skip to content

Commit 724e4d5

Browse files
committed
* updates for separate hosting client/server
* update readme * styling tweaks
1 parent 68a3a28 commit 724e4d5

File tree

15 files changed

+845
-471
lines changed

15 files changed

+845
-471
lines changed

README.md

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
# Blog List app
1+
# <p align="center"> Blog List app </p>
22

3-
**An app that lets users manage blog links, share, like and comment.**
3+
### <p align="center">An app that lets users manage blog links, share, like and comment.</p>
44

5-
**[Try it out]()**
5+
### <p align="center"><a href="https://blog-list-pi.now.sh/">Try it out</a></p>
66

7-
Test username/password: **tim / tim**
7+
<p align="center">Test username/password: tim / tim</p>
8+
9+
## About
810

911
Frontend: React, Redux, Styled-components, Storybook
1012

11-
Backend: Node, Express, MongoDB, Mongoose
13+
Backend: Node, Express, MongoDB, Mongoose, Jest
1214

1315
This project started out as my submission in part 7 of the
1416
[Full Stack course](https://fullstackopen.com/en/part7)
1517
to learn redux and grew from there.
1618

1719
## Dev build
1820

19-
Requirements (works on version):
21+
Server requirements (works on version):
2022

2123
- node 11.10
2224
- mongodb v3.4 or mongo cloud - sign up for a
2325
[free account](https://www.mongodb.com/cloud)
2426

25-
Server secrets are stored in `.env` in project root so create the env
26-
vars like the example below:
27-
28-
```
29-
MONGODB_URI=mongodb+srv://tim:<password>@fullstackopen-9zjso.mongodb.net/blog-list?retryWrites=true&w=majority
30-
PORT=3003
31-
SECRET=jsonwebtokensuperdupersecret
32-
```
27+
Secrets are stored in `/server/.env`. See `/server/.env.example`.
3328

3429
The client uses create-react-app and proxies all backend requests.
35-
In order for the client to talk to the server, the port chosen above
36-
needs to match the one inside `package.json` in `/client`
30+
In order for the client to talk to the server, the port chosen in `.env`
31+
needs to match the one in `/client/package.json`
3732

3833
```
3934
"proxy": "http://localhost:3003",
@@ -51,18 +46,20 @@ npm run server
5146
npm run storybook (for visual testing)
5247
```
5348

54-
## Notes
49+
## Additional
5550

5651
Things I added on top of the project requirements:
5752

58-
- pagination with client caching
59-
- sort by fields
60-
- multiple blog deletion
61-
- form validation
62-
- a design system...sort of (check out the storybook)
63-
- notifications
64-
- mobile responsive
65-
- react-spring animations
53+
- [x] pagination with client caching
54+
- [x] sort by fields
55+
- [x] multiple blog deletion
56+
- [x] form validation
57+
- [x] a design system...sort of (check out the storybook)
58+
- [x] notifications
59+
- [x] mobile responsive
60+
- [x] react-spring animations
61+
62+
## Outcome
6663

6764
Learnt some notable things:
6865

client/now.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"build": {
3+
"env": {
4+
"REACT_APP_API_URL": "@API_URL"
5+
}
6+
}
7+
}

client/package-lock.json

Lines changed: 3 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"@quickbaseoss/babel-plugin-styled-components-css-namespace": "1.0.0-rc4",
99
"axios": "^0.19.0",
1010
"body-scroll-lock": "2.7.0",
11-
"http-proxy-middleware": "0.20.0",
1211
"immer": "4.0.0",
1312
"lodash": "4.17.15",
1413
"normalizr": "3.4.1",
@@ -17,13 +16,11 @@
1716
"react-dom": "^16.8.6",
1817
"react-helmet": "5.2.1",
1918
"react-loading-skeleton": "1.3.0",
20-
"react-morph": "0.4.0",
2119
"react-onclickoutside": "6.9.0",
2220
"react-redux": "7.1.0",
2321
"react-router-dom": "5.0.1",
2422
"react-scripts": "3.4.1",
2523
"react-spring": "8.0.27",
26-
"react-transition-group": "4.3.0",
2724
"redux": "4.0.4",
2825
"redux-thunk": "2.3.0",
2926
"reselect": "4.0.0",

client/src/components/Blog/styled.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const CircleIcon = styled(CircleGlyph)`
4444
`;
4545

4646
export const Title = styled.div`
47-
font-weight: 600;
47+
font-weight: 500;
4848
font-size: 1.3rem;
4949
line-height: 1.2;
5050
text-transform: capitalize;
@@ -71,6 +71,7 @@ export const Metadata = styled.span`
7171
`;
7272

7373
export const BlogLink = styled.a`
74+
margin-top: 5px;
7475
${ellipsis("100%")};
7576
`;
7677

client/src/components/BlogList/BlogItem/styled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const ListItem = styled.li`
2727

2828
export const Title = styled(filterProps(Link, ["isLink"]))`
2929
pointer-events: ${({ isLink }) => (isLink ? "auto" : "none")};
30-
font-weight: ${({ isLink }) => (isLink ? "auto" : "normal")};
30+
font-weight: ${({ isLink }) => (isLink ? "450" : "normal")};
3131
text-decoration: none;
3232
color: ${({ theme }) => theme.fontDark};
3333
font-size: 1.1rem;

client/src/components/GlobalStyle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default createGlobalStyle`
4747
4848
a {
4949
color: ${({ theme }) => theme.primaryLight};
50-
font-weight: 550;
50+
font-weight: 400;
5151
text-decoration: none;
5252
&:hover {
5353
text-decoration: underline;

client/src/components/Theme.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const makeBrightLevels = (name, baseColor, percent = 0.1) => ({
55
[name + "Lighter"]: lighten(percent * 3, baseColor),
66
[name + "Light"]: lighten(percent, baseColor),
77
[name + "Dark"]: darken(percent, baseColor),
8-
[name + "Darker"]: darken(percent * 2, baseColor)
8+
[name + "Darker"]: darken(percent * 2, baseColor),
99
});
1010

1111
const theme = {
@@ -26,7 +26,7 @@ const theme = {
2626
return transparentize(0.9, this.valid);
2727
},
2828
...makeBrightLevels("fontDark", "#000"),
29-
fontLight: "#fff"
29+
...makeBrightLevels("fontLight", "#fff"),
3030
};
3131

3232
export default theme;

client/src/store/apiMiddleware.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Axios from "axios";
22
import { batch } from "react-redux";
33
import { getActionName } from "../reducers/utils";
44

5-
export default ({ getState, dispatch }) => next => async action => {
5+
export default ({ getState, dispatch }) => (next) => async (action) => {
66
if (action.HTTP_ACTION === undefined) return next(action);
77

88
const {
@@ -15,7 +15,7 @@ export default ({ getState, dispatch }) => next => async action => {
1515
onSuccess,
1616
onFail,
1717
headers,
18-
notify
18+
notify,
1919
} = action.HTTP_ACTION;
2020
const actionName = getActionName(type);
2121
const { currentUser } = getState();
@@ -26,10 +26,11 @@ export default ({ getState, dispatch }) => next => async action => {
2626
next({ type, notify });
2727
try {
2828
const response = await Axios({
29+
baseURL: process.env.REACT_APP_API_URL,
2930
method,
3031
headers,
3132
url,
32-
data: payload
33+
data: payload,
3334
});
3435
let retVal;
3536
batch(() => {
@@ -38,8 +39,8 @@ export default ({ getState, dispatch }) => next => async action => {
3839
type: `${actionName}_SUCCESS`,
3940
data,
4041
response: response.data,
41-
schema
42-
}
42+
schema,
43+
},
4344
});
4445
onSuccess && next(onSuccess()); // OnSuccess(data, transformResp) UNUSED?
4546
});
@@ -57,7 +58,7 @@ export default ({ getState, dispatch }) => next => async action => {
5758
error = { message: "Request was made but no response was received" };
5859
} else {
5960
error = {
60-
message: `There was a problem setting up the request (${err.message})`
61+
message: `There was a problem setting up the request (${err.message})`,
6162
};
6263
}
6364
console.error(
@@ -73,7 +74,7 @@ export default ({ getState, dispatch }) => next => async action => {
7374
const retVal = next({
7475
type: `${actionName}_FAIL`,
7576
error,
76-
notify
77+
notify,
7778
});
7879
onFail && next(onFail(error));
7980
return retVal;

server/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MONGODB_URI=<mongodb connection string URI>
2+
PORT=<server port>
3+
SECRET=<json web token secret>

0 commit comments

Comments
 (0)