Comparing version 1.0.1 to 1.1.0
@@ -43,8 +43,11 @@ /**! | ||
if (stat.isDirectory()) { | ||
// nesting is supported, for only one layer at most, `/api/parents/:parent_id/objects/:id` | ||
// nesting is supported, for only two layers at most, `/api/parents/:parent_id/children/:child_id/objects/:id` | ||
if (level === 0) { | ||
registerDir(app, prefix + '/' + name + '/:parent_id', filepath, level + 1); | ||
} else if (level === 1) { | ||
registerDir(app, prefix + '/' + name + '/:child_id', filepath, level + 1 ); | ||
} else { | ||
app.loggers.coreLogger.warn('[egg:rest] for directory "%s", the nesting is too deep(%d layer), one layer at most, which means `/api/parents/:parent_id/objects/:id`', filepath, level + 1); | ||
} | ||
continue; | ||
@@ -51,0 +54,0 @@ } |
1.0.1 / 2016-09-12 | ||
1.1.0 / 2016-09-29 | ||
================== | ||
* support two level deep nested resources (#6) | ||
* docs: replace parameter url (#5) | ||
@@ -6,0 +7,0 @@ |
{ | ||
"name": "egg-rest", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Restful API plugin for egg", | ||
@@ -10,5 +10,4 @@ "eggPlugin": { | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "npm run lint -- --fix && npm run test-local", | ||
"test-local": "egg-bin test", | ||
"lint": "eslint . --fix", | ||
"test": "egg-bin test", | ||
"cov": "egg-bin cov", | ||
@@ -15,0 +14,0 @@ "ci": "npm run lint && npm run cov", |
@@ -95,14 +95,18 @@ # egg-rest | ||
Nesting of one layer at most is supported. | ||
Nesting of two layer at most is supported. | ||
method | url | file path | controller name | ||
--- | --- | --- | --- | ||
**GET** | `/doc/api/{parents}/:parent_id/{objects}?per_page={per_page}&page={page}` | `app/apis/{parents}/{objects}.js` | **index()** | ||
**GET** | `/doc/api/{parents}/:parent_id/{objects}/:id` | `app/apis/{parents}/{objects}.js` | **show()** | ||
**POST** | `/doc/api/{parents}/:parent_id/{objects}` | `app/apis/{parents}/{objects}.js` | **create()** | ||
**PUT** | `/doc/api/{parents}/:parent_id/{objects}/:id` | `app/apis/{parents}/{objects}.js` | **update()** | ||
**DELETE** | `/doc/api/{parents}/:parent_id/{objects}/:id[s]` | `app/apis/{parents}/{objects}.js` | **destroy()** | ||
**GET** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}?per_page={per_page}&page={page}` | `app/apis/{parents}/{objects}.js` | **index()** | ||
**GET** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}/:id` | `app/apis/{parents}/{objects}.js` | **show()** | ||
**POST** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}` | `app/apis/{parents}/{objects}.js` | **create()** | ||
**PUT** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}/:id` | `app/apis/{parents}/{objects}.js` | **update()** | ||
**DELETE** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}/:id[s]` | `app/apis/{parents}/{objects}.js` | **destroy()** | ||
Example: `/doc/api/posts/111/replies/1` => `app/apis/posts/replies.js` => params: `{ parent_id: 111, id: 1 }` | ||
Example: `/api/users/3/posts/1/replies/2` => params: `{ parent_id: 3, child_id: 2, id: 1 }`. The idea is that you can can retrieve the ids from `this.params`, | ||
which you get values of `{ users: '3', posts: '1', replies: '2' }`. It matches the file path `/api/users/3/posts/1/replies/2`. | ||
**Note:** It does not support more than three level deep nesting. Example: `/api/users/3/posts/1/replies/2/answer` won't match file path | ||
`apis/users/posts/replies/answer.js`. Currently, it can only retrieve maximum three query parameters. | ||
Controllers can be loaded from `index.js` in parent directory. | ||
@@ -109,0 +113,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
33152
417
779
2