vanta-api 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +17 -17
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@ This repository provides a robust, feature-rich, and secure solution for buildin
10
10
 
11
11
  1. [Installation & Setup](#installation--setup)
12
12
  2. [Overview](#overview)
13
- 3. [VantaApi Class Methods](#VantaApi-class-methods)
13
+ 3. [ApiFeatures Class Methods](#ApiFeatures-class-methods)
14
14
  - [filter()](#filter)
15
15
  - [sort()](#sort)
16
16
  - [limitFields()](#limitfields)
@@ -54,7 +54,7 @@ npm install --save-dev jest
54
54
 
55
55
  ## Overview
56
56
 
57
- The **VantaApi** class processes incoming query parameters and progressively builds an aggregation pipeline. The package supports:
57
+ The **ApiFeatures** class processes incoming query parameters and progressively builds an aggregation pipeline. The package supports:
58
58
 
59
59
  - **Advanced filtering, sorting, and field selection.**
60
60
  - **Pagination with defaults** (defaults to page 1 and limit 10 if not provided), with the maximum limit based on the user's role.
@@ -67,7 +67,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
67
67
 
68
68
  ---
69
69
 
70
- ## VantaApi Class Methods
70
+ ## ApiFeatures Class Methods
71
71
 
72
72
  ### filter()
73
73
  - **Description:**
@@ -76,7 +76,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
76
76
 
77
77
  ```javascript
78
78
  // URL: /api/products?status=active&price[gte]=100
79
- const features = new VantaApi(Product, req.query);
79
+ const features = new ApiFeatures(Product, req.query);
80
80
  features.filter();
81
81
  // Pipeline adds: { $match: { status: "active", price: { $gte: 100 }, isActive: true } }
82
82
  ```
@@ -88,7 +88,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
88
88
 
89
89
  ```javascript
90
90
  // URL: /api/products?sort=-price,createdAt
91
- const features = new VantaApi(Product, req.query);
91
+ const features = new ApiFeatures(Product, req.query);
92
92
  features.sort();
93
93
  // Pipeline adds: { $sort: { price: -1, createdAt: 1 } }
94
94
  ```
@@ -100,7 +100,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
100
100
 
101
101
  ```javascript
102
102
  // URL: /api/products?fields=name,price,category,password
103
- const features = new VantaApi(Product, req.query);
103
+ const features = new ApiFeatures(Product, req.query);
104
104
  features.limitFields();
105
105
  // Pipeline adds: { $project: { name: 1, price: 1, category: 1 } }
106
106
  ```
@@ -112,7 +112,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
112
112
 
113
113
  ```javascript
114
114
  // URL: /api/products?page=2&limit=20
115
- const features = new VantaApi(Product, req.query, "user");
115
+ const features = new ApiFeatures(Product, req.query, "user");
116
116
  features.paginate();
117
117
  // Pipeline adds: { $skip: 20 } and { $limit: 20 }
118
118
  ```
@@ -128,7 +128,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
128
128
 
129
129
  ```javascript
130
130
  // URL: /api/products?populate=category,brand
131
- const features = new VantaApi(Product, req.query);
131
+ const features = new ApiFeatures(Product, req.query);
132
132
  features.populate();
133
133
  ```
134
134
 
@@ -136,7 +136,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
136
136
 
137
137
  ```javascript
138
138
  const populateOptions = { path: "category", select: "name description" };
139
- const features = new VantaApi(Product, req.query);
139
+ const features = new ApiFeatures(Product, req.query);
140
140
  features.populate(populateOptions);
141
141
  ```
142
142
 
@@ -148,7 +148,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
148
148
  { path: "category", select: "name description" },
149
149
  { path: "category", select: "name", populate: { path: "subCategory", select: "title" } }
150
150
  ];
151
- const features = new VantaApi(Product, req.query, "admin");
151
+ const features = new ApiFeatures(Product, req.query, "admin");
152
152
  features.populate(populateArray);
153
153
  ```
154
154
 
@@ -159,7 +159,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
159
159
 
160
160
  ```javascript
161
161
  const manualFilter = { category: "electronics" };
162
- const features = new VantaApi(Product, { status: "active" });
162
+ const features = new ApiFeatures(Product, { status: "active" });
163
163
  features.addManualFilters(manualFilter).filter();
164
164
  ```
165
165
 
@@ -169,7 +169,7 @@ The **VantaApi** class processes incoming query parameters and progressively bui
169
169
  - **Usage Example:**
170
170
 
171
171
  ```javascript
172
- const features = new VantaApi(Product, req.query);
172
+ const features = new ApiFeatures(Product, req.query);
173
173
  const result = await features
174
174
  .filter()
175
175
  .sort()
@@ -276,11 +276,11 @@ This middleware sets the appropriate HTTP status code and JSON error message whe
276
276
  ### Example 1: Basic Query
277
277
 
278
278
  ```javascript
279
- import VantaApi from "./api-features.js";
279
+ import ApiFeatures from "./api-features.js";
280
280
  import Product from "./models/product.js";
281
281
 
282
282
  // URL: /api/products?status=active&price[gte]=100&sort=-price,createdAt&fields=name,price,category&page=1&limit=10&populate=category,brand
283
- const features = new VantaApi(Product, req.query, "user");
283
+ const features = new ApiFeatures(Product, req.query, "user");
284
284
  const result = await features
285
285
  .filter()
286
286
  .sort()
@@ -298,7 +298,7 @@ console.log(result);
298
298
  ```javascript
299
299
  const query = { status: "active" };
300
300
  const manualFilter = { category: "electronics" };
301
- const features = new VantaApi(Product, query, "user");
301
+ const features = new ApiFeatures(Product, query, "user");
302
302
  features.addManualFilters(manualFilter).filter();
303
303
  const result = await features.execute();
304
304
  console.log(result);
@@ -312,7 +312,7 @@ const populateArray = [
312
312
  { path: "category", select: "name description" },
313
313
  { path: "category", select: "name", populate: { path: "subCategory", select: "title" } }
314
314
  ];
315
- const features = new VantaApi(Product, req.query, "admin");
315
+ const features = new ApiFeatures(Product, req.query, "admin");
316
316
  const result = await features.populate(populateArray).execute();
317
317
  console.log(result);
318
318
  ```
@@ -335,7 +335,7 @@ GET /api/products?
335
335
 
336
336
  ```javascript
337
337
  // URL: /api/products?status=active
338
- const features = new VantaApi(Product, req.query);
338
+ const features = new ApiFeatures(Product, req.query);
339
339
  const result = await features
340
340
  .filter() // Defaults to page 1 and limit 10
341
341
  .execute();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanta-api",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Advanced API features and security configuration for Node.js/MongoDB.",
5
5
  "main": "src/api-features.js",
6
6
  "scripts": {