node-responder 1.2.0 → 1.2.1
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 +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,6 +139,27 @@ router.use(responder());
|
|
|
139
139
|
|
|
140
140
|
## 📖 API Reference
|
|
141
141
|
|
|
142
|
+
### Quick Reference
|
|
143
|
+
|
|
144
|
+
| Method | Status | When to use |
|
|
145
|
+
| -------------------------------------------- | ------ | ------------------------------------------ |
|
|
146
|
+
| `res.ok(data?, message?)` | 200 | Successful GET request |
|
|
147
|
+
| `res.created(data?, message?)` | 201 | New resource created |
|
|
148
|
+
| `res.noContent()` | 204 | Delete or update with no data to return |
|
|
149
|
+
| `res.success(data?, message?, statusCode?)` | custom | Custom success status code |
|
|
150
|
+
| `res.badRequest(message?, errors?)` | 400 | Validation failed |
|
|
151
|
+
| `res.unauthorized(message?)` | 401 | Not logged in or no token |
|
|
152
|
+
| `res.forbidden(message?)` | 403 | Logged in but no permission |
|
|
153
|
+
| `res.notFound(message?)` | 404 | Resource does not exist |
|
|
154
|
+
| `res.conflict(message?)` | 409 | Duplicate data (e.g. email already exists) |
|
|
155
|
+
| `res.unprocessable(message?, errors?)` | 422 | Business logic validation failed |
|
|
156
|
+
| `res.tooManyRequests(message?, retryAfter?)` | 429 | Rate limit exceeded |
|
|
157
|
+
| `res.serverError(message?)` | 500 | Unexpected server-side error |
|
|
158
|
+
| `res.error(message?, statusCode?, errors?)` | custom | Custom error status code |
|
|
159
|
+
| `res.paginate(data, message?, pagination?)` | 200 | Paginated list response |
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
142
163
|
### ✅ Success Methods
|
|
143
164
|
|
|
144
165
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-responder",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Modern, standardized API response middleware for Express.js — with TypeScript support, pagination, and shorthand methods.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|