Skip to content

rithmschool/hack-or-snooze-api-v3

Repository files navigation

Hack or Snooze API

Live URL

This API is currently running here: https://hack-or-snooze.herokuapp.com/

Documentation

Full interactive API documentation available here: https://hackorsnoozeapi.docs.apiary.io

Development

Prerequisites to Running Locally

  1. Install Node
  2. Install MongoDB
  3. (For Testing) Install Dredd npm i dredd -g

How to Run Locally

  1. npm i
  2. In a new tab, mongod (unless it's already running, e.g. brew services start mongodb)
  3. 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.

Notes on Data Model

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 usernames, which are user-generated, and storyIds, which are auto-generated by the server. At no point should the MongoDB _id / primary key be exposed to the API users.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published