Skip to content

Commit cf600ee

Browse files
before deploy
2 parents e4cf7cc + dff35df commit cf600ee

27 files changed

+611
-758
lines changed

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Fit-Journal with NodeJS
22

3-
View project at www.fit-journal.herokuapp.com (currently still in development)
3+
View project at www.fit-journal.herokuapp.com
44

55
Track your workout history whether it be resistance or cardiovascular training, all in one place!
66
This project is built on Node and Express using CRUD standard practices.
77
Create an account.
88
Choose from a database of various exercises.
99
View your workout history and progress.
1010

11+
![alt text](./public/img/fit_j_thumb.png)
12+
1113
## Getting Started
1214

1315
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
@@ -17,13 +19,6 @@ These instructions will get you a copy of the project up and running on your loc
1719
Tests completed with faker.js and Chai
1820
To supply data for testing and assertions
1921

20-
### Break down into end to end tests
21-
22-
Explain what these tests test and why
23-
24-
```
25-
Give an example
26-
```
2722

2823
### And coding style tests
2924

app/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ module.exports = {
99
NOT_FOUND: 404,
1010
INTERNAL_SERVER_ERROR: 500,
1111
},
12-
MONGO_URL: process.env.MONGO_URL || 'mongodb://localhost:27017/fit-journal',
13-
// MONGO_URL: process.env.MONGO_URL || 'mongodb://ds237932.mlab.com:37932/fit-journal',
12+
13+
MONGO_URL: process.env.MONGO_URL || 'mongodb:admin:"W\!nner05"//ds237932.mlab.com:37932/fit-journal',
1414
TEST_MONGO_URL: process.env.TEST_MONGO_URL || 'mongodb://localhost:27017/test-fit-journal',
1515
JWT_SECRET: process.env.JWT_SECRET || 'default',
1616
JWT_EXPIRY: process.env.JWT_EXPIRY || '7d',

app/exercise/exercise.router.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ exerciseRouter.post('/', (request, response) => {
2525

2626
const validation = Joi.validate(newExercise, ExerciseJoiSchema);
2727
if (validation.error) {
28-
console.log("Validation Error")
28+
2929
return response.status(HTTP_STATUS_CODES.BAD_REQUEST).json({
3030
error: validation.error
3131
});
@@ -43,7 +43,7 @@ exerciseRouter.post('/', (request, response) => {
4343

4444
// RETRIEVE Exercises
4545
exerciseRouter.get('/', (request, response) => {
46-
console.log("Retrieving All Exercises");
46+
4747
Exercise.find()
4848
.then(exercises => {
4949
return response.status(HTTP_STATUS_CODES.OK).json(
@@ -52,25 +52,20 @@ exerciseRouter.get('/', (request, response) => {
5252
);
5353
})
5454
.catch(error => {
55-
// Step 2B: If an error ocurred, return an error HTTP status code and the error in JSON format.
5655
return response.status(HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR).json(error);
5756
});
5857
});
5958
// RETRIEVE ONE EXERCISE
6059
exerciseRouter.get('/:id', (request, response) => {
6160

62-
// Step 1: Attempt to retrieve a specific user using Mongoose.Model.findById()
63-
// https://mongoosejs.com/docs/api.html#model_Model.findById
6461
Exercise.findById(request.params.id)
6562
.then(exercise => {
66-
console.log(exercise)
67-
// Step 2A: Return the correct HTTP status code, and the user correctly formatted via serialization.
68-
// return response.status(HTTP_STATUS_CODES.OK).json(user.serialize());
63+
64+
6965
return response.json(exercise);
7066

7167
})
7268
.catch(error => {
73-
// Step 2B: If an error ocurred, return an error HTTP status code and the error in JSON format.
7469
return response.status(HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR).json(error);
7570
});
7671
});

app/server.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ passport.use(localStrategy);
3434
passport.use(jwtStrategy);
3535

3636
//MIDLEWARE
37-
app.use(morgan('combined')); //allows morgan to intercept and alog all http requests to console
38-
app.use(express.json()); // Required so AJAX request JSON data payload can be parsed and saved into request.body
37+
app.use(morgan('combined'));
38+
app.use(express.json());
3939
app.use(express.static('./public'));
4040
app.use(express.urlencoded({ extended: true }));
4141

4242
//ROUTER SETUP
4343
app.use('/api/auth', authRouter);
44-
app.use('/api/user', userRouter); //Redirects all calls to /api/user to userRouter
44+
app.use('/api/user', userRouter);
4545
app.use('/api/home', workoutRouter);
4646
app.use('/api/exercises', exerciseRouter);
4747
app.use(express.static('./public', {
@@ -91,18 +91,14 @@ function startServer(testEnv) {
9191
}
9292

9393
function stopServer() {
94-
//Step 1: disconnect from MongoDB database using Mongoose
9594
return mongoose
9695
.disconnect()
9796
.then(() => new Promise((resolve, reject) => {
98-
//Step 2: Shut down the ExpressJS sever
9997
server.close(err => {
10098
if (err) {
101-
//Step 3A: if an error occurred while shutting down, print out the error to the console and resolve promise
10299
console.error(err);
103100
return reject(err);
104101
} else {
105-
//Step 3B: If server shutdown correctly, log success message.
106102
console.log('Express sever stopped');
107103
resolve();
108104
}

app/sets/sets.router.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ setsRouter.post('/', (req, res) => {
2626
}
2727
const validation = Joi.validate(newSet, SetJoiSchema);
2828
if (validation.error) {
29-
console.log("Set Validation Error")
3029
return res.status(HTTP_STATUS_CODES.BAD_REQUEST).json({
3130
error: validation.error
3231
});

app/user/user.model.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
//Connects to mongoDB
21
const mongoose = require('mongoose');
3-
//Validates data
42
const Joi = require('joi');
5-
//Encrypts passwords
63
const bcrypt = require('bcryptjs');
74

8-
// Each Mongoose schema maps to a MongoDB collection and defines the shape of the documents within that collection.
95
const userSchema = new mongoose.Schema({
106
name: {
117
type: String,

app/user/user.router.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ userRouter.post('/', (request, response) => {
6363

6464
// RETRIEVE USERS
6565
userRouter.get('/', (request, response) => {
66-
console.log("Retrieving All Users");
6766
User.find()
6867
.then(users => {
6968

@@ -82,7 +81,6 @@ userRouter.get('/:userid', (request, response) => {
8281
User.findById(request.params.userid)
8382
.then(user => {
8483

85-
console.log(request.params.userid)
8684
return response.status(HTTP_STATUS_CODES.OK).json(user.serialize());
8785

8886
})

0 commit comments

Comments
 (0)