Skip to content

Commit cf78cf6

Browse files
author
Tane Morgan
authored
Merge pull request #18 from tanem/update-docs
Tidy up docs
2 parents 93c1d42 + e5d0ecb commit cf78cf6

8 files changed

+50
-55
lines changed

README.md

+14-55
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,27 @@
55

66
> An [Express](https://expressjs.com/) and [Bookshelf](http://bookshelfjs.org/) based backend implementation of the [RealWorld API Spec](https://github.com/gothinkster/realworld/tree/master/api).
77
8-
## table of contents
9-
10-
* [intent](#intent)
11-
* [getting started](#getting-started)
12-
* [running tests](#running-tests)
13-
* [implementation details](#implementation-details)
14-
* [structure](#structure)
15-
* [group by coupling](#group-by-coupling)
16-
* [initializers](#initializers)
17-
* [configuration](#configuration)
18-
* [testing](#testing)
19-
* [outside in](#outside-in)
20-
* [run in band](#run-in-band)
21-
* [prefer snapshot tests](#prefer-snapshot-tests)
22-
* [license](#license)
23-
24-
## intent
8+
## Table of Contents
9+
10+
* [Background](#background)
11+
* [Getting Started](#getting-started)
12+
* [Running Tests](#running-tests)
13+
* [Documentation](#documentation)
14+
* [License](#license)
15+
16+
## Background
2517

2618
This project was created in order to familiarise myself with some key technologies in use at my day job. It's not intended to be production ready, but PRs that address this and any other issues are welcome!
2719

28-
## getting started
20+
## Getting Started
2921

3022
Ensure [Docker Compose](https://docs.docker.com/compose/install/) is installed, then:
3123

3224
1. Clone this repo.
3325
2. Change to the above dir.
3426
3. Run `yarn docker:start` to start the app.
3527

36-
## running tests
28+
## Running Tests
3729

3830
Run the full test suite with:
3931

@@ -59,43 +51,10 @@ Then in a new terminal window, assuming you've cloned the `realworld-server-test
5951
$ java -jar target/realworld-server-tester-0.1.0-SNAPSHOT-standalone.jar http://localhost:3000/api
6052
```
6153

62-
## implementation details
63-
64-
High-level overview of some important decisions made building the app. Check the code comments for more detail too.
65-
66-
### structure
67-
68-
#### group by coupling
69-
70-
The general rule with modules in the `lib/` dir is "things that change together, stay together". This is largely a personal preference after having to maintain apps that instead group by function, but the approach is also summarised nicely in this [express code structure](https://github.com/focusaurus/express_code_structure) example.
71-
72-
Each module is usually an Express sub-app. Code that is shared across modules is either promoted (e.g. middleware), or is added to a specific app-wide registry (e.g. models).
73-
74-
#### initializers
75-
76-
The initialization procedure is based on [the approach taken by the Locomotive framework](http://www.locomotivejs.org/guide/initialization/). App initialization steps have been split into separate functions in
77-
the `initializers/` folder, and are run in a certain order. Any required app-wide references are set on the [`app.locals`](https://expressjs.com/en/4x/api.html#app.locals) object.
78-
79-
### configuration
80-
81-
Configuration is handled by [node-convict](https://github.com/mozilla/node-convict), which provides context on each setting and enables validation and early failures for when the configuration is wrong.
82-
83-
Some values are required, and there are also some defaults which can be overridden if required. You can do this via environment-specific configuration files, for example `development.json` and `test.json`. Environment variables are also respected, see [precedence order](https://github.com/mozilla/node-convict#precendence-order) for more information.
84-
85-
### testing
86-
87-
#### outside-in
88-
89-
The preference is to create high-level tests first in order to test the API end-to-end from a user’s perspective. From there we can drop down into lower-level tests like unit tests (this hasn't yet been done in this repo). See [Testing from the Outside-In](https://robots.thoughtbot.com/testing-from-the-outsidein) for more information.
90-
91-
#### run in band
92-
93-
Since we're hitting a real DB via our functional tests, we want to run them serially in the current process using Jest's [`runInBand`](https://facebook.github.io/jest/docs/en/cli.html#runinband) option so they remain isolated. If the test suite gets expanded to include unit tests that don't hit the DB for example, then we may want to be specific about when we use that flag in order to keep the tests running as fast as possible.
94-
95-
#### prefer snapshot tests
54+
## Documentation
9655

97-
Where possible Jest's [snapshot testing](https://facebook.github.io/jest/docs/en/snapshot-testing.html) feature is used in order to validate key parts of the API response. Where this is not straightforward, for example when the response returns creation dates which vary over time, we've fallen back to more specific assertions.
56+
- [Docs](/docs/)
9857

99-
## license
58+
## License
10059

10160
MIT

docs/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Table of Contents
2+
3+
## Structure
4+
5+
- [Group by Coupling](structure/group-by-coupling.md)
6+
- [Initializers](structure/initializers.md)
7+
- [Configuration](structure/configuration.md)
8+
9+
## Testing
10+
11+
- [Outside-In](testing/outside-in.md)
12+
- [Run in Band](testing/run-in-band.md)
13+
- [Prefer Snapshot Tests](testing/prefer-snapshot-tests.md)

docs/structure/configuration.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Configuration
2+
3+
Configuration is handled by [node-convict](https://github.com/mozilla/node-convict), which provides context on each setting and enables validation and early failures for when the configuration is wrong.
4+
5+
Some values are required, and there are also some defaults which can be overridden if required. You can do this via environment-specific configuration files, for example `development.json` and `test.json`. Environment variables are also respected, see [precedence order](https://github.com/mozilla/node-convict#precendence-order) for more information.

docs/structure/group-by-coupling.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Group by Coupling
2+
3+
The general rule with modules in the `lib/` dir is "things that change together, stay together". This is largely a personal preference after having to maintain apps that instead group by function, but the approach is also summarised nicely in this [express code structure](https://github.com/focusaurus/express_code_structure) example.
4+
5+
Each module is usually an Express sub-app. Code that is shared across modules is either promoted (e.g. middleware), or is added to a specific app-wide registry (e.g. models).

docs/structure/initializers.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Initializers
2+
3+
The initialization procedure is based on [the approach taken by the Locomotive framework](http://www.locomotivejs.org/guide/initialization/). App initialization steps have been split into separate functions in
4+
the `initializers/` folder, and are run in a certain order. Any required app-wide references are set on the [`app.locals`](https://expressjs.com/en/4x/api.html#app.locals) object.

docs/testing/outside-in.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Outside-In
2+
3+
The preference is to create high-level tests first in order to test the API end-to-end from a user’s perspective. From there we can drop down into lower-level tests like unit tests (this hasn't yet been done in this repo). See [Testing from the Outside-In](https://robots.thoughtbot.com/testing-from-the-outsidein) for more information.

docs/testing/prefer-snapshot-tests.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Prefer Snapshot Tests
2+
3+
Where possible Jest's [snapshot testing](https://facebook.github.io/jest/docs/en/snapshot-testing.html) feature is used in order to validate key parts of the API response. Where this is not straightforward, for example when the response returns creation dates which vary over time, we've fallen back to more specific assertions.

docs/testing/run-in-band.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Run in Band
2+
3+
Since we're hitting a real DB via our functional tests, we want to run them serially in the current process using Jest's [`runInBand`](https://facebook.github.io/jest/docs/en/cli.html#runinband) option so they remain isolated. If the test suite gets expanded to include unit tests that don't hit the DB for example, then we may want to be specific about when we use that flag in order to keep the tests running as fast as possible.

0 commit comments

Comments
 (0)