Skip to content

Commit

Permalink
get rid of tests, lol
Browse files Browse the repository at this point in the history
  • Loading branch information
hueter committed Nov 15, 2018
1 parent 4ffb5aa commit 77635e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 448 deletions.
23 changes: 3 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,21 @@ Full interactive API documentation available here:
### How to Run Locally

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

### How to Run Tests

[Dredd](http://dredd.org/en/latest/index.html) tests run by reading the
documentation blueprint against a running server. It must be installed globally
to run tests.

```bash
npm i -g dredd
```

After starting the database and server, run the commmand:

```bash
dredd documentation.apib http://localhost:5000 -f ./tests/api-hooks.js
```

### Notes on Data Model

We have two main entities: **User** and **Story**.

1 User has many stories. 1 User also has many favorites (which are stories).
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](http://mongoosejs.com/docs/populate.html) 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.
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.
Loading

0 comments on commit 77635e8

Please sign in to comment.