Skip to content

Commit 7519f76

Browse files
committed
Updated the Readme.
1 parent 225f684 commit 7519f76

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

Diff for: README.md

+28-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# FSJS Project #11: Course-Rating-API-Express
2-
A REST API using Express. The API will provide a way for users to review educational courses: users can see a list of courses in a database; add courses to the database; and add reviews for a specific course. This project uses REST API design, Node.js, and Express to create API routes, along with Mongoose and MongoDB for data modeling, validation, and persistence.
2+
This project uses REST API design, Node.js, and Express to create API routes, along with Mongoose and MongoDB for data modeling, validation, and persistence.
3+
The API will provide a way for users to:
4+
* add a new user
5+
* review educational courses: users can see a list of courses in a database;
6+
* add courses to the database;
7+
* add reviews for a specific course.
38

49

510
## Installation
@@ -42,20 +47,38 @@ To POST a new user enter the data in this format:
4247
{
4348
"fullName": "Bob Jones",
4449
"emailAddress": "[email protected]",
45-
"password": "pass"
50+
"password": "password"
4651
}
4752
```
4853

49-
POST a new review in this format, where the `user` value is the users `_id`:
54+
POST a new review in this format, with valid email & password in Postmans Basic Auth:
5055

5156
```json
5257
{
53-
"user": "5ba97554b7116463fd924849",
5458
"rating": 4,
5559
"review": "Here is a new review, such wow."
5660
}
5761
```
5862

59-
* Run the Tests in the console:
63+
* POST a new course
64+
65+
```json
66+
{
67+
"reviews": [],
68+
"title": "New Course Title",
69+
"description": "Lorem gibson euro-pop narrative Tessier-Ashpool rain realism human RAF assassin carbon sign shanty town sub-orbital ICE Tokyo.",
70+
"estimatedTime": "12 hours",
71+
"materialsNeeded": "Lots of stuff",
72+
"steps": [
73+
{
74+
"stepNumber": 1,
75+
"title": "Dungeon Financing with Blockchain",
76+
"description": "Collect gold pieces."
77+
}
78+
]
79+
}
80+
```
81+
82+
* Run the Tests in the console with:
6083

6184
`$ mocha`

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "techdegree-fullstackjs-course-review-rest-api",
2+
"name": "course-review-rest-api",
33
"version": "1.0.0",
44
"description": "",
55
"main": "src/index.js",

Diff for: src/database/models.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,9 @@ UserSchema.statics.authenticate = function(creds, callback) {
6969
};
7070

7171

72-
/* A pre save hook on the user schema that uses the bcrypt npm package encrypts the password property before saving it to the database */
72+
// A pre save hook on the user schema that uses the bcrypt npm package encrypts the password property before saving it to the database
7373
UserSchema.pre('save', function(next) {
74-
/*
75-
Due to the nature of this in an arrow function you can't use them for Mongoose hooks. this in arrow functions aren't rebindable, but Mongoose wants to rebind this to be the document being saved. You should use an anonymous function instead (i.e., function() {})
76-
`.pre()` is Mongoose hook.
77-
The data assigned to `this` in Mongoose's pre save hook function is the data that Mongoose will write to MongoDB.
78-
*/
74+
// Due to the nature of this in an arrow function you can't use them for Mongoose hooks.
7975
const saltRounds = 10;
8076
var user = this;
8177
// only hash the password if it has been modified or is new.

Diff for: src/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
const express = require('express');
55
const app = express();
66

7-
// const bodyParser = require('body-parser');
87
const logger = require('morgan');
98
const mongoose = require('mongoose');
109
const apiRoutes = require('./routes/routes');

Diff for: src/routes/routes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ router.get('/users', middle.credentials, middle.callAuthen, (req, res) =>{
2222
// Creates a user, sets the Location header to "/", and returns no content.
2323
router.post('/users', (req, res, next) => {
2424
var user = new User(req.body);
25-
user.save(function(error, users) {
25+
user.save(function(error) {
2626
if(error) return next(error);
2727
res.redirect('/');
2828
res.status(201);

0 commit comments

Comments
 (0)