Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit 20e7007

Browse files
committed
docs(manual): Add more manual pages (handlers, installation)
1 parent 8242539 commit 20e7007

6 files changed

Lines changed: 81 additions & 3 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"**/.DS_Store": true,
88
"**/.nyc_output": true,
99
"**/node_modules": true,
10-
"**/dist": true
10+
"**/dist": true,
11+
"packages/createrest/docs": true
1112
}
1213
}

packages/createrest/.esdoc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"files": [
2020
"./esdocs/installation.md",
2121
"./esdocs/express.md",
22-
"./esdocs/koa.md"
22+
"./esdocs/koa.md",
23+
"./esdocs/handlers.md"
2324
]
2425
}
2526
}

packages/createrest/esdocs/express.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
npm install express createrest createrest-express
77
```
88

9+
Installation manual for Express [here](http://expressjs.com/starter/installing.html)
10+
11+
912
## Source code
1013

1114
```js
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Handlers
2+
3+
## [get](/class/lib/index.js~Maker.html#instance-method-get)
4+
5+
Add handler for GET route.
6+
7+
```js
8+
createRest(root => {
9+
root.get('/', () => console.log('Handle GET /'))
10+
11+
root.scope('demo', demo => {
12+
demo.get('/', () => console.log('Handle GET /demo'))
13+
})
14+
})
15+
```

packages/createrest/esdocs/installation.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Installation
22

3+
## NPM packages
4+
5+
[createrest](https://npmjs.com/createrest)
6+
7+
```shell
8+
npm install --save createrest
9+
```
10+
311
## Import functions
412

513
If you use babel or latest build of node.js:
@@ -13,3 +21,44 @@ For commonjs based modules:
1321
```js
1422
const { createRest, flattenRoutes, printRoutes } = require('createrest')
1523
```
24+
25+
## Express
26+
27+
[createrest-express](https://npmjs.com/createrest-express)
28+
29+
```shell
30+
npm install --save createrest createrest-express express
31+
```
32+
33+
```js
34+
const Express = require('express')
35+
const { createExpressMiddleware } = require('createrest-express')
36+
const routes = require('./routes')
37+
38+
const app = Express()
39+
40+
app.use(createExpressMiddleware(routes))
41+
42+
app.listen(8000)
43+
```
44+
45+
## Koa2
46+
47+
[createrest-koa](https://npmjs.com/createrest-koa)
48+
49+
```shell
50+
npm install --save createrest createrest-koa koa@2
51+
```
52+
```js
53+
const Express = require('koa')
54+
const { createKoaRouter } = require('createrest-express')
55+
const routes = require('./routes')
56+
57+
const app = new Koa()
58+
const router = createKoaRouter(routes)
59+
60+
app.use(router.routes(), router.allowedMethods())
61+
62+
app.listen(8000)
63+
```
64+

packages/createrest/esdocs/styles.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ h3 .right-info {
149149
color: #fdd687;
150150
}
151151

152+
.content .detail > h3 {
153+
background-color: transparent;
154+
}
155+
152156
.content .detail + .detail {
153157
margin-top: 50px;
154158
}
@@ -176,7 +180,7 @@ table.summary span.access {
176180
}
177181

178182
.inner-link-active, :target {
179-
background: rgba(255, 52, 52, 0.33);
183+
background: rgba(255, 52, 52, 0.33) !important;
180184
border-right: 3px solid #ffb44c;
181185
}
182186

@@ -275,3 +279,8 @@ table.summary span.access {
275279
.search-result li.selected {
276280
background: rgba(255, 52, 52, 0.33);
277281
}
282+
283+
.manual-index .manual-user-index,
284+
.manual-index .manual-card {
285+
border-color: #5c6773;
286+
}

0 commit comments

Comments
 (0)