Implementation from Stephen
- Packages used:
express
andmongoose
- Install packages before running files
- To run the files, enter
$node app.js
- I used
Postman
to do the check the endpoints
POST /users
to create new userGET /users/{userId}
to view an user by IDPOST /users/{userId}/posts
to create a new post under an userGET /users/{userId}/posts
to list all posts owned by an usersGET /users/{userIdd}/posts/{postId}
to get one post owned by an users
posts
-> All posts in the databaseposts/limit
-> Returns posts with a certain amount (default 200). For exampleposts/limit=20
.posts/title
-> Matches posts with a title (default all posts). For exampleposts/title=book
.posts/sort
-> Returns posts which are sorted by either title or time(default by ascending order). For example,posts/sort=title:desc,createdAt:desc
POST user/random/:number
-> Creates (number) users with random names, DoB, and 10 posts of each created user.- Package used to generate random data:
node-random-name
,random-birthday
,node-randomstring
andrandom-date-generator
.