express-project-builder 1.0.9 → 1.0.10
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 +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -283,3 +283,25 @@ import AppError from "../../errors/AppError";
|
|
|
283
283
|
// Throw an application error with status code, path, and message
|
|
284
284
|
throw new AppError(404, "user", "User not found");
|
|
285
285
|
```
|
|
286
|
+
|
|
287
|
+
- /src/middlewares/**auth.ts**
|
|
288
|
+
Middleware for authenticating requests. This middleware checks for a valid JWT token in the request headers and verifies its authenticity. If the token is valid, the user information is added to the request object (`req.user`) for further processing.
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
// In your route file
|
|
292
|
+
import auth from "../../middlewares/auth";
|
|
293
|
+
|
|
294
|
+
// Protect a route with specific roles
|
|
295
|
+
router.get(
|
|
296
|
+
"/users",
|
|
297
|
+
auth("user", "admin", "superAdmin", "developer"), // Only users with these roles can access
|
|
298
|
+
UsersControllers.getAllUsers
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
// Protect a route without role checking (just verify token)
|
|
302
|
+
router.get(
|
|
303
|
+
"/profile",
|
|
304
|
+
auth("user", "admin", "superAdmin", "developer", true), // Any authenticated user can access
|
|
305
|
+
UsersController.getUserProfile
|
|
306
|
+
);
|
|
307
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-project-builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
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",
|