This API is currently running here: https://hack-or-snooze.herokuapp.com/
Full interactive API documentation available here: https://hackorsnoozeapi.docs.apiary.io
- Install Node
- Install MongoDB
- (For Testing) Install Dredd
npm i dredd -g
npm i
- In a new tab,
mongod
(unless it's already running, e.g.brew services start mongodb
) - In the first tab,
npm run dev
Server runs on http://localhost:5000 by default.
You can also pass any environment variables in a .env
file.
We have two main entities: User and Story.
1 User has many stories that they posted. Many users also have many favorites (which are stories).
User stories
and favorites
exist as arrays of Mongoose refs which are populated in the retrieval methods.
Each Story document maintains a username
, which is not a DB reference. This is because Story does not need to know about User in the sense that you would never query a list of stories and have embedded user profiles, whereas the inverse (show stories embedded on User profiles) makes more sense.
Also, the routing (and consequently, much of the querying) is based on username
s, which are user-generated, and storyId
s, which are auto-generated by the server. At no point should the MongoDB _id
/ primary key be exposed to the API users.