You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 8, 2025. It is now read-only.
|`develop`|[](https://circleci.com/gh/davesag/api-server-boilerplate/tree/develop)|[](https://codecov.io/gh/davesag/api-server-boilerplate)| Work in progress |
10
-
|`master`|[](https://circleci.com/gh/davesag/api-server-boilerplate/tree/master)|[](https://codecov.io/gh/davesag/api-server-boilerplate)| Latest Production Release |
9
+
<!-- prettier-ignore -->
10
+
| Branch | Tests | Code Coverage | Comments |
11
+
| ------ | ----- | ------------- | -------- |
12
+
|`develop`|[](https://circleci.com/gh/davesag/api-server-boilerplate/tree/develop)|[](https://codecov.io/gh/davesag/api-server-boilerplate)| Work in progress |
13
+
|`master`|[](https://circleci.com/gh/davesag/api-server-boilerplate/tree/master)|[](https://codecov.io/gh/davesag/api-server-boilerplate)| Latest Production Release |
11
14
12
15
## Configuration
13
16
@@ -19,49 +22,78 @@ Set the following environment variables
19
22
20
23
## API Routes
21
24
22
-
There's a single API route, `/api/v1/ping` that simply returns some information about the server.
25
+
If it's running locally (see below) point a browser at any of the following routes:
I write a lot of APIs and have distilled my current best-practice into this codebase to save myself time.
37
+
I write a lot of APIs and have distilled my current best-practice into this codebase to save myself time, and as example code for other developers wondering how to do this sort of stuff.
38
+
39
+
## What do you do with it?
29
40
30
41
Just clone it or fork it, nuke the existing `.git` data and replace with your own `git init` and `git flow init` edit the `README.md` file, add your own details to `api.yml` and add routes to `src/api/` as you like.
31
42
32
-
## What's not in this
43
+
## What's included?
33
44
34
-
Heaps. I've paired this right back to the simplest, most generic API I could, so there's no
45
+
- a couple of root-level API routes and simple controllers
35
46
36
-
- authentication (add `passport` and update `src/utils/makeApp` and add appropriate security blocks to `api.yml`)
37
-
- middleware (roll your own and update `src/utils/makeApp`)
38
-
- monitoring
39
-
- sockets or event listeners
40
-
- databases, search systems, etc
47
+
-`src/api/ping`
48
+
-`src/api/versions`
41
49
42
-
## What is in this
50
+
- a versioned API route and controller
51
+
52
+
-`src/api/v1/hello`
43
53
44
-
- a single API route and simple controller (`src/api/v1/ping`)
45
-
- support for asynchronous routes via [`route-async`](https://github.com/davesag/route-async)
46
54
- automatic linking of swagger paths to controllers using [`swagger-routes-express`](https://github.com/davesag/swagger-routes-express) and [`traverse-folders`](https://github.com/davesag/traverse-folders)
47
55
- automatic generation of API docs using [`swagger-ui-express`](https://github.com/scottie1984/swagger-ui-express)
48
56
- simple logging (swap out the code in `src/utils/logger` to add your own)
49
57
- standardised [`node-http-error`](https://github.com/carsondarling/node-http-error) and [`http-status-codes`](https://github.com/prettymuchbryce/http-status-codes) and simple `generic` and `notFound` error handlers
50
58
- the swagger editor as an easy to invoke docker image
51
59
-[`dotenv`](https://github.com/motdotla/dotenv) support
- unit testing via [`mocha`](https://mochajs.org), [`sinon`](https://sinonjs.org), [`chai`](https://www.chaijs.com), and [`proxyquire`](https://github.com/thlorenz/proxyquire)
56
70
-`request` and `response` mocks using [`mock-req-res`](https://github.com/davesag/mock-req-res)
57
71
- 100% unit test coverage using [`nyc`](https://github.com/istanbuljs/nyc)
58
72
- integration testing using [`supertest`](https://github.com/visionmedia/supertest)
59
73
- code quality using [`eslint`](https://eslint.org) and [`prettier`](https://prettier.io)
74
+
- mutation testing with [`stryker-mutator`](https://stryker-mutator.io)
I've paired this right back to the simplest, most generic API I could, so there's no
81
+
82
+
- authentication (add `passport` and update `src/utils/makeApp` and add appropriate security blocks to `api.yml`)
83
+
- example of an asynchronous route via [`route-async`](https://github.com/davesag/route-async)
84
+
- rate limiting
85
+
- middleware (roll your own and update `src/utils/makeApp`)
86
+
- monitoring
87
+
- sockets or event listeners
88
+
- databases, search systems, etc
89
+
63
90
## Development
64
91
92
+
### Prerequisites
93
+
94
+
-[NodeJS](htps://nodejs.org), version 10.15.3 (LTS) or better. (I use [`nvm`](https://github.com/creationix/nvm) to manage Node versions — `brew install nvm`.)
95
+
-[Docker](https://www.docker.com) if you want to use the Swagger Editor. (Use [Docker for Mac](https://docs.docker.com/docker-for-mac/), not the `homebrew` version)
96
+
65
97
### To build and run locally
66
98
67
99
Clone this (or better yet, fork it then clone your fork)
@@ -83,13 +115,16 @@ You can put environment variables in a `.env` file.
0 commit comments