express-project-builder 1.0.5 → 1.0.7
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.
- package/README.md +125 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ A powerful and professional [Express.js project generator CLI](https://www.npmjs
|
|
|
11
11
|
- [Quick Start](#Quick-Start)
|
|
12
12
|
- [Key Elements](#Key-Elements)
|
|
13
13
|
- [Folder Structure](#Folder-Structure)
|
|
14
|
+
- [Packages](#Packages)
|
|
15
|
+
- [Examples](#Examples)
|
|
14
16
|
|
|
15
17
|
# [Quick Start](#Quick-Start)
|
|
16
18
|
|
|
@@ -131,3 +133,126 @@ my-test-project/
|
|
|
131
133
|
├── package.json
|
|
132
134
|
└── tsconfig.json
|
|
133
135
|
```
|
|
136
|
+
|
|
137
|
+
## [Packages](#Packages)
|
|
138
|
+
|
|
139
|
+
### Dependencies
|
|
140
|
+
|
|
141
|
+
- [axios (1.12.2)](https://www.npmjs.com/package/axios)
|
|
142
|
+
- [bcryptjs (3.0.2)](https://www.npmjs.com/package/bcryptjs)
|
|
143
|
+
- [cookie-parser (1.4.7)](https://www.npmjs.com/package/cookie-parser)
|
|
144
|
+
- [cors (2.8.5)](https://www.npmjs.com/package/cors)
|
|
145
|
+
- [dotenv (16.6.1)](https://www.npmjs.com/package/dotenv)
|
|
146
|
+
- [eslint-plugin-prettier (5.5.4)](https://www.npmjs.com/package/eslint-plugin-prettier)
|
|
147
|
+
- [express (5.1.0)](https://www.npmjs.com/package/express)
|
|
148
|
+
- [jsonwebtoken (9.0.2)](https://www.npmjs.com/package/jsonwebtoken)
|
|
149
|
+
- [mongoose (8.19.1)](https://www.npmjs.com/package/mongoose)
|
|
150
|
+
- [multer (2.0.2-lts.1)](https://www.npmjs.com/package/multer)
|
|
151
|
+
- [node-cache (5.1.2)](https://www.npmjs.com/package/node-cache)
|
|
152
|
+
- [nodemailer (7.0.6)](https://www.npmjs.com/package/nodemailer)
|
|
153
|
+
- [@prisma/client (6.16.1)](https://www.npmjs.com/package/@prisma/client)
|
|
154
|
+
- [zod (3.24.1)](https://www.npmjs.com/package/zod)
|
|
155
|
+
|
|
156
|
+
### Development Dependencies
|
|
157
|
+
|
|
158
|
+
- [@eslint/js (9.35.0)](https://www.npmjs.com/package/@eslint/js)
|
|
159
|
+
- [@types/cookie-parser (1.4.9)](https://www.npmjs.com/package/@types/cookie-parser)
|
|
160
|
+
- [@types/cors (2.8.19)](https://www.npmjs.com/package/@types/cors)
|
|
161
|
+
- [@types/express (5.0.3)](https://www.npmjs.com/package/@types/express)
|
|
162
|
+
- [@types/jsonwebtoken (9.0.10)](https://www.npmjs.com/package/@types/jsonwebtoken)
|
|
163
|
+
- [@types/multer (2.0.0)](https://www.npmjs.com/package/@types/multer)
|
|
164
|
+
- [@types/nodemailer (7.0.1)](https://www.npmjs.com/package/@types/nodemailer)
|
|
165
|
+
- [@typescript-eslint/eslint-plugin (8.43.0)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
|
|
166
|
+
- [@typescript-eslint/parser (8.43.0)](https://www.npmjs.com/package/@typescript-eslint/parser)
|
|
167
|
+
- [eslint (9.35.0)](https://www.npmjs.com/package/eslint)
|
|
168
|
+
- [eslint-config-prettier (10.1.8)](https://www.npmjs.com/package/eslint-config-prettier)
|
|
169
|
+
- [globals (16.4.0)](https://www.npmjs.com/package/globals)
|
|
170
|
+
- [prisma (6.16.1)](https://www.npmjs.com/package/prisma)
|
|
171
|
+
- [prettier (3.6.2)](https://www.npmjs.com/package/prettier)
|
|
172
|
+
- [ts-node-dev (2.0.0)](https://www.npmjs.com/package/ts-node-dev)
|
|
173
|
+
- [typescript (5.9.2)](https://www.npmjs.com/package/typescript)
|
|
174
|
+
- [typescript-eslint (8.43.0)](https://www.npmjs.com/package/typescript-eslint)
|
|
175
|
+
|
|
176
|
+
## [Examples](#Examples)
|
|
177
|
+
|
|
178
|
+
- /src/app/builder/**MongooseQueryBuilder.ts** <br/>
|
|
179
|
+
A fluent API for building complex MongoDB queries with Mongoose. Simplifies dynamic query construction for search, filtering, sorting, pagination, and field selection in a chainable interface.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// In your controller/service:
|
|
183
|
+
import MongooseQueryBuilder from "../../builder/MongooseQueryBuilder";
|
|
184
|
+
|
|
185
|
+
// Extract query parameters from request (e.g., ?search=keyword&page=1&limit=10)
|
|
186
|
+
const { page, limit, sort, search, fields, ...filters } = req.query;
|
|
187
|
+
|
|
188
|
+
// Create a new query builder instance
|
|
189
|
+
const docQuery = new MongooseQueryBuilder(YourModel.find(), req.query)
|
|
190
|
+
|
|
191
|
+
// Search in specified text fields (e.g., name, description, category)
|
|
192
|
+
.search(["name", "description", "category"])
|
|
193
|
+
|
|
194
|
+
// Apply filters dynamically (e.g., status=active, category=tech)
|
|
195
|
+
.filter()
|
|
196
|
+
|
|
197
|
+
// Sort results (e.g., ?sort=name asc,sort=-createdAt desc)
|
|
198
|
+
.sort()
|
|
199
|
+
|
|
200
|
+
// Paginate results (e.g., ?page=1&limit=10)
|
|
201
|
+
.paginate()
|
|
202
|
+
|
|
203
|
+
// Select specific fields (e.g., ?fields=name,price,description)
|
|
204
|
+
.fields();
|
|
205
|
+
|
|
206
|
+
// Execute the query and get results
|
|
207
|
+
const result = await docQuery.modelQuery;
|
|
208
|
+
|
|
209
|
+
// Get pagination metadata (total count, page, limit, total pages)
|
|
210
|
+
const meta = await docQuery.countTotal();
|
|
211
|
+
|
|
212
|
+
// Return the results and metadata from service
|
|
213
|
+
return {
|
|
214
|
+
result,
|
|
215
|
+
meta,
|
|
216
|
+
};
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
- /src/app/builder/**PrismaQueryBuilder.ts** <br/>
|
|
220
|
+
A fluent API for building complex SQL queries with Prisma. Simplifies dynamic query construction for search, filtering, sorting, pagination, and field selection in a chainable interface.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
// In your controller/service:
|
|
224
|
+
import PrismaQueryBuilder from "../../builder/PrismaQueryBuilder";
|
|
225
|
+
|
|
226
|
+
// Extract query parameters from request (e.g., ?search=keyword&page=1&limit=10)
|
|
227
|
+
const { page, limit, sort, search, fields, ...filters } = req.query;
|
|
228
|
+
|
|
229
|
+
// Create a new query builder instance
|
|
230
|
+
const docQuery = new PrismaQueryBuilder(YourModel.find(), req.query)
|
|
231
|
+
|
|
232
|
+
// Search in specified text fields (e.g., name, description, category)
|
|
233
|
+
.search(["name", "description", "category"])
|
|
234
|
+
|
|
235
|
+
// Apply filters dynamically (e.g., status=active, category=tech)
|
|
236
|
+
.filter()
|
|
237
|
+
|
|
238
|
+
// Sort results (e.g., ?sort=name asc,sort=-createdAt desc)
|
|
239
|
+
.sort()
|
|
240
|
+
|
|
241
|
+
// Paginate results (e.g., ?page=1&limit=10)
|
|
242
|
+
.paginate()
|
|
243
|
+
|
|
244
|
+
// Select specific fields (e.g., ?fields=name,price,description)
|
|
245
|
+
.fields();
|
|
246
|
+
|
|
247
|
+
// Execute the query and get results
|
|
248
|
+
const result = await docQuery.modelQuery;
|
|
249
|
+
|
|
250
|
+
// Get pagination metadata (total count, page, limit, total pages)
|
|
251
|
+
const meta = await docQuery.countTotal();
|
|
252
|
+
|
|
253
|
+
// Return the results and metadata from service
|
|
254
|
+
return {
|
|
255
|
+
result,
|
|
256
|
+
meta,
|
|
257
|
+
};
|
|
258
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-project-builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "A powerful and professional Express.js project generator CLI that instantly scaffolds a production-ready backend with TypeScript, modular architecture, and built-in support for MongoDB (Mongoose) or PostgreSQL (Prisma). Includes authentication, error handling, rate limiting, file upload, caching, and utility functions—so you can focus on building features instead of boilerplate. Perfect for kickstarting your next Express.js API project with best practices and modern tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/bin/index.js",
|