New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

egg-rest

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-rest - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

2

app.js

@@ -6,3 +6,3 @@ 'use strict';

// load all js files in app/apis/ directory automatically
// load all js files in app/api/ directory automatically
module.exports = app => {

@@ -9,0 +9,0 @@ // remove existed rest plugin configuration to prevent error configurations.

2.1.0 / 2018-06-21
==================
* feat: prefer app/api rather than apis (#17)
* docs: fix typo at README (#15)
2.0.0 / 2017-11-23

@@ -3,0 +9,0 @@ ==================

@@ -13,3 +13,7 @@ 'use strict';

// load rest api
const apisDir = path.join(app.config.baseDir, 'app', 'apis');
let apiDir = path.join(app.config.baseDir, 'app', 'api');
if (!fs.existsSync(apiDir)) {
// backwards compatible
apiDir = path.join(app.config.baseDir, 'app', 'apis');
}
// register routing automatically

@@ -20,6 +24,6 @@ let urlprefix = app.config.rest.urlprefix;

app.logger.info(`[egg-rest] mount rest api: ${urlprefix} -> ${apisDir}`);
app.logger.info(`[egg-rest] mount rest api: ${urlprefix} -> ${apiDir}`);
// load the middleware only and if only the rest plugin enabled
registerDir(app, urlprefix, apisDir, 0);
registerDir(app, urlprefix, apiDir, 0);

@@ -51,3 +55,3 @@ function registerDir(app, prefix, dir, level) {

let objectNames = path.basename(name, '.js');
// apis/sites/index.js => GET /sites
// api/sites/index.js => GET /sites
if (level >= 1 && objectNames === 'index') {

@@ -54,0 +58,0 @@ objectNames = path.basename(dir);

{
"name": "egg-rest",
"version": "2.0.0",
"version": "2.1.0",
"description": "Restful API plugin for egg",

@@ -58,3 +58,3 @@ "eggPlugin": {

"engines": {
"node": ">= 8.0.0"
"node": ">=8.0.0"
},

@@ -61,0 +61,0 @@ "author": "shaoshuai0102 <shaoshuai0102@gmail.com>",

@@ -48,3 +48,3 @@ # egg-rest

- `urlperfix`: Prefix of rest api url. Default to `/api/`
- `urlprefix`: Prefix of rest api url. Default to `/api/`
- `authRequest`: a function for getting some value of authentication

@@ -80,3 +80,3 @@ - `authIgnores`: allow some request to ignore authentication

Controllers in files matching `${baseDir}/app/apis/**.js` will be loaded automatically according to routing rules.
Controllers in files matching `${baseDir}/app/api/**.js` will be loaded automatically according to routing rules.

@@ -101,7 +101,7 @@ __Caution__

--- | --- | --- | ---
**GET** | `/doc/api/{objects}[?per_page={per_page}&page={page}]` | `app/apis/{objects}.js` | **index()**
**GET** | `/doc/api/{objects}/:id` | `app/apis/{objects}.js` | **show()**
**POST** | `/doc/api/{objects}` | `app/apis/{objects}.js` | **create()**
**PUT** | `/doc/api/{objects}/:id` | `app/apis/{objects}.js` | **update()**
**DELETE** | `/doc/api/{objects}/:id[s]` | `app/apis/{objects}.js` | **destroy()**
**GET** | `/doc/api/{objects}[?per_page={per_page}&page={page}]` | `app/api/{objects}.js` | **index()**
**GET** | `/doc/api/{objects}/:id` | `app/api/{objects}.js` | **show()**
**POST** | `/doc/api/{objects}` | `app/api/{objects}.js` | **create()**
**PUT** | `/doc/api/{objects}/:id` | `app/api/{objects}.js` | **update()**
**DELETE** | `/doc/api/{objects}/:id[s]` | `app/api/{objects}.js` | **destroy()**

@@ -114,7 +114,7 @@ ### Nested Resources

--- | --- | --- | ---
**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()**
**GET** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}?per_page={per_page}&page={page}` | `app/api/{parents}/{objects}.js` | **index()**
**GET** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}/:id` | `app/api/{parents}/{objects}.js` | **show()**
**POST** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}` | `app/api/{parents}/{objects}.js` | **create()**
**PUT** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}/:id` | `app/api/{parents}/{objects}.js` | **update()**
**DELETE** | `/doc/api/{parents}/:parent_id/{children}/:child_id/{objects}/:id[s]` | `app/api/{parents}/{objects}.js` | **destroy()**

@@ -125,7 +125,7 @@ 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`,

**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.
`api/users/posts/replies/answer.js`. Currently, it can only retrieve maximum three query parameters.
Controllers can be loaded from `index.js` in parent directory.
Example: `/doc/api/{parents}` => `app/apis/{parents}/index.js`
Example: `/doc/api/{parents}` => `app/api/{parents}/index.js`

@@ -230,3 +230,3 @@ ---

```js
// app/apis/user.js
// app/api/user.js
// routing: GET /doc/api/users

@@ -287,3 +287,3 @@ exports.index = function* (next) {

```js
// app/apis/user.js
// app/api/user.js
// routing: GET /doc/api/users/:id

@@ -337,3 +337,3 @@ exports.show = function* (next) {

```js
// app/apis/user.js
// app/api/user.js
// routing: GET /doc/api/users/:ids

@@ -392,3 +392,3 @@ exports.show = function* (next) {

```js
// app/apis/user.js
// app/api/user.js
// Routing: POST /doc/api/users

@@ -444,3 +444,3 @@ exports.create = function* (next) {

```js
// app/apis/user.js
// app/api/user.js
// Routing: PUT /doc/api/users/:id

@@ -508,3 +508,3 @@ exports.update = function* (next) {

```js
// app/apis/user.js
// app/api/user.js
// Routing: DELETE /doc/api/users/:id

@@ -511,0 +511,0 @@ exports.destroy = function* (next) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc