Skip to content

Commit f41bcc9

Browse files
author
Shawn Toubeau
committed
Adds to ReadME
1 parent 4a21b67 commit f41bcc9

File tree

8 files changed

+142
-616
lines changed

8 files changed

+142
-616
lines changed

Diff for: README.md

+102-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,102 @@
1-
# ActiviX
1+
# ActiviX
2+
3+
ActiviX is a at home mental health support tool that aids people who suffer from mental health by encouraging them to perform small but meaningful tasks in hope of leading them to a happier life.
4+
5+
This is a Wentworth Institute of Technology senior project by Shawn Toubeau, Morgan Whittemore, and Zachary Griffin.
6+
7+
## Application Details
8+
9+
This repo contains both the frontend React client and a **mock** Express backend server. The current server was built to help design the API routes and allow the client to experience a normal user flow. Eventually it will be replaced with a Django web server that Morgan is working on which will be responsible for more of our backend operations.
10+
11+
## Getting Started
12+
13+
### Package Manager
14+
15+
The client and the server both use `yarn` to manage 3rd party packages and starting the applications. If you don't have yarn installed, you can install it from [here](https://classic.yarnpkg.com/en/docs/install).
16+
17+
### Installing dependencies
18+
19+
You can install dependencies for both the client and the server by running the following in the root directory.
20+
21+
```bash
22+
yarn run install-dep
23+
```
24+
25+
### Environment Variables
26+
27+
Both applications depend on some environment variables in order to function. The later sections will tell you how to set them up but for now you can get them ready.
28+
29+
The first 2 will be a set of VAPID keys which are used by the Push and Notification APIs.
30+
To generate them, run
31+
32+
```bash
33+
./server/node_modules/.bin/web-push generate-vapid-keys
34+
```
35+
36+
The other will be a MongoDB URI for connecting to a MongoDB database. If you do not have a instance setup already you can follow this [guide](https://docs.atlas.mongodb.com/getting-started/) to do so.
37+
38+
### Frontend
39+
40+
To setup the client, first change into the `client` folder
41+
42+
```bash
43+
cd client
44+
```
45+
46+
and create a `.env` file with the following content. Be sure to insert your **Public VAPID** key that you generated in the previous section.
47+
48+
```env
49+
REACT_APP_PUBLIC_VAPID_KEY=<INSERT-KEY-HERE>
50+
```
51+
52+
You can start the client by running
53+
54+
```bash
55+
yarn run start
56+
```
57+
58+
and access it at [http://localhost:3000](http://localhost:3000)
59+
60+
### Backend
61+
62+
To setup the server, first change into the `server` folder
63+
64+
```bash
65+
cd server
66+
```
67+
68+
and create a `.env` file with the following content. Be sure to insert your **Public VAPID** key, **Private VAPID** key, and **MongoDB URI** that you generated in the previous section.
69+
70+
(**Note**: The **SESSION_SECRET** and **JWT_SECRET** are both string values that are used to sign tokens)
71+
72+
```env
73+
MONGO_URI=<INSERT-URI-HERE>
74+
PUBLIC_VAPID_KEY=<INSERT-KEY-HERE>
75+
PRIVATE_VAPID_KEY=<INSERT-KEY-HERE>
76+
SESSION_SECRET=secret
77+
JWT_SECRET=secret
78+
```
79+
80+
You can start the server by running
81+
82+
(**Note**: If you get an error when you try to start the server, re-running the command a 2nd time usually fixes it. This is because when we run the server in dev mode, it has to transpile the es6 Javascript down to es5 in order to be executable and it tries to start the server at the same time it does that.)
83+
84+
```bash
85+
yarn run start
86+
```
87+
88+
and access it at [http://localhost:8000](http://localhost:8000)
89+
90+
## Building for Production
91+
92+
You can build both the client and the server from the root project directory by running
93+
94+
```bash
95+
yarn run build
96+
```
97+
98+
This will output production builds at `./client/build` and `./server/dist` where you can then run the app with
99+
100+
```bash
101+
yarn run prod
102+
```

Diff for: client/public/arrow_right-01.png

-17.3 KB
Binary file not shown.

Diff for: client/yarn.lock

+15-15
Original file line numberDiff line numberDiff line change
@@ -1597,9 +1597,9 @@
15971597
integrity sha512-oZ0Ib5I4Z2pUEcoo95cT1cr6slco9WY7yiPpG+RGNkj8YcYgJnM7pXmYmorNOReh8MIGcKSqXyeGjxnr8YiZbA==
15981598

15991599
"@types/babel__core@^7.1.0":
1600-
version "7.1.6"
1601-
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.6.tgz#16ff42a5ae203c9af1c6e190ed1f30f83207b610"
1602-
integrity sha512-tTnhWszAqvXnhW7m5jQU9PomXSiKXk2sFxpahXvI20SZKu9ylPi8WtIxueZ6ehDWikPT0jeFujMj3X4ZHuf3Tg==
1600+
version "7.1.7"
1601+
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.7.tgz#1dacad8840364a57c98d0dd4855c6dd3752c6b89"
1602+
integrity sha512-RL62NqSFPCDK2FM1pSDH0scHpJvsXtZNiYlMB73DgPBaG1E38ZYVL+ei5EkWRbr+KC4YNiAUNBnRj+bgwpgjMw==
16031603
dependencies:
16041604
"@babel/parser" "^7.1.0"
16051605
"@babel/types" "^7.0.0"
@@ -1729,9 +1729,9 @@
17291729
integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==
17301730

17311731
"@types/react-dom@*", "@types/react-dom@^16.9.0":
1732-
version "16.9.5"
1733-
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.5.tgz#5de610b04a35d07ffd8f44edad93a71032d9aaa7"
1734-
integrity sha512-BX6RQ8s9D+2/gDhxrj8OW+YD4R+8hj7FEM/OJHGNR0KipE1h1mSsf39YeyC81qafkq+N3rU3h3RFbLSwE5VqUg==
1732+
version "16.9.6"
1733+
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.6.tgz#9e7f83d90566521cc2083be2277c6712dcaf754c"
1734+
integrity sha512-S6ihtlPMDotrlCJE9ST1fRmYrQNNwfgL61UB4I1W7M6kPulUKx9fXAleW5zpdIjUQ4fTaaog8uERezjsGUj9HQ==
17351735
dependencies:
17361736
"@types/react" "*"
17371737

@@ -1765,17 +1765,17 @@
17651765
redux ">= 3.7.2"
17661766

17671767
"@types/react-router@*", "@types/react-router@^5.1.4":
1768-
version "5.1.4"
1769-
resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.4.tgz#7d70bd905543cb6bcbdcc6bd98902332054f31a6"
1770-
integrity sha512-PZtnBuyfL07sqCJvGg3z+0+kt6fobc/xmle08jBiezLS8FrmGeiGkJnuxL/8Zgy9L83ypUhniV5atZn/L8n9MQ==
1768+
version "5.1.5"
1769+
resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.5.tgz#7b2f9b7cc3d350e92664c4e38c0ef529286fe628"
1770+
integrity sha512-RZPdCtZympi6X7EkGyaU7ISiAujDYTWgqMF9owE3P6efITw27IWQykcti0BvA5h4Mu1LLl5rxrpO3r8kHyUZ/Q==
17711771
dependencies:
17721772
"@types/history" "*"
17731773
"@types/react" "*"
17741774

17751775
"@types/react@*", "@types/react@^16.9.0":
1776-
version "16.9.30"
1777-
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.30.tgz#4750857769803c36afeb9ed30139bb77f9607223"
1778-
integrity sha512-nx+ixghmJkzcDYhtqvmf/jPcBvyH87yfLM+dUDH2n8lE356t18p2flj3mzkT/VO0N1wh6RCjtmWGFI3r/KhCxw==
1776+
version "16.9.31"
1777+
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.31.tgz#6a543529766c8934ec8a89667376c2e73e9e2636"
1778+
integrity sha512-NpYJpNMWScFXtx3A2BJMeew2G3+9SEslVWMdxNJ6DLvxIuxWjY1bizK9q5Y1ujhln31vtjmhjOAYDr9Xx3k9FQ==
17791779
dependencies:
17801780
"@types/prop-types" "*"
17811781
csstype "^2.2.0"
@@ -1828,9 +1828,9 @@
18281828
"@types/yargs-parser" "*"
18291829

18301830
"@types/yup@^0.26.30":
1831-
version "0.26.33"
1832-
resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.26.33.tgz#301faab47b952a4a5f9a06246942cc7cbd09cd95"
1833-
integrity sha512-QzgcNfDtRIph8CjfoWiu+MJiOUp25Yo7FthuOHLVbtCTyonjOo2YRsFzKo3csDWbTXlw5NedOFH0Nje7yipCrA==
1831+
version "0.26.34"
1832+
resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.26.34.tgz#199329f9fee5074a7385b4a4a25d1559db628aef"
1833+
integrity sha512-/zH/Yuwl2vC5fgPE+Qtv67iI/o50qLJJsR0KVc86cpDlY2IsRv3yJop1v/9hfNrgy7J8J5BpJM4BMhyFE3QE4w==
18341834

18351835
"@typescript-eslint/eslint-plugin@^2.10.0":
18361836
version "2.26.0"

Diff for: package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
"scripts": {
1010
"build:client": "cd client && yarn install && yarn run build",
1111
"build:server": "cd server && yarn install && yarn run build",
12-
"build": "yarn run build:client && yarn run build:server"
12+
"build": "yarn run build:client && yarn run build:server",
13+
"install-dep:client": "cd client && yarn",
14+
"install-dep:server": "cd server && yarn",
15+
"install-dep": "yarn run install-dep:client && yarn run install-dep:server",
16+
"prod": "cd server && NODE_ENV=production node ./dist/app.js"
1317
},
1418
"repository": {
1519
"type": "git",
@@ -21,8 +25,5 @@
2125
"bugs": {
2226
"url": "https://github.com/ShawnToubeau/ActiviX/issues"
2327
},
24-
"homepage": "https://github.com/ShawnToubeau/ActiviX#readme",
25-
"dependencies": {
26-
"concurrently": "^5.1.0"
27-
}
28+
"homepage": "https://github.com/ShawnToubeau/ActiviX#readme"
2829
}

Diff for: server/src/app.js

+9-14
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,21 @@ app.use(bodyParser.urlencoded({ extended: true }));
4646
app.use(express.json());
4747
app.use(cors());
4848

49-
const sessionSecret = process.env.SESSION_SECRET;
50-
51-
if (sessionSecret) {
52-
app.use(
53-
session({
54-
secret: sessionSecret,
55-
resave: true,
56-
saveUninitialized: true
57-
})
58-
);
59-
} else {
60-
console.error('ERROR: Please provide a session secret');
61-
}
49+
const sessionSecret = process.env.SESSION_SECRET || 'secret';
50+
51+
app.use(
52+
session({
53+
secret: sessionSecret,
54+
resave: true,
55+
saveUninitialized: true
56+
})
57+
);
6258

6359
// Passport config
6460
app.use(passport.initialize());
6561
passportConfig(passport);
6662

6763
if (process.env.NODE_ENV === 'production') {
68-
console.log('APP.js PROD');
6964
app.use(compression());
7065
app.use(morgan('common'));
7166

Diff for: server/src/config/passport.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const dbUrl = 'http://localhost:5000';
44

55
const opts = {
66
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
7-
secretOrKey: 'secret'
7+
secretOrKey: process.env.JWT_SECRET || 'secret'
88
};
99

1010
export const passportConfig = passport => {

0 commit comments

Comments
 (0)