@0layimika/api-response-kit 0.1.0 → 0.1.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 +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,16 +55,16 @@ type ApiError = {
|
|
|
55
55
|
```
|
|
56
56
|
## Installation
|
|
57
57
|
```bash
|
|
58
|
-
npm install api-response-kit
|
|
58
|
+
npm install @0layimika/api-response-kit
|
|
59
59
|
|
|
60
|
-
yarn add api-response-kit
|
|
60
|
+
yarn add @0layimika/api-response-kit
|
|
61
61
|
|
|
62
|
-
pnpm add api-response-kit
|
|
62
|
+
pnpm add @0layimika/api-response-kit
|
|
63
63
|
```
|
|
64
64
|
## Basic Usage
|
|
65
65
|
### Success Helpers
|
|
66
66
|
```ts
|
|
67
|
-
import { Ok, Created, NoContent } from "api-response-kit"
|
|
67
|
+
import { Ok, Created, NoContent } from "@0layimika/api-response-kit"
|
|
68
68
|
|
|
69
69
|
return Ok(user)
|
|
70
70
|
return Created(newUser)
|
|
@@ -72,7 +72,7 @@ return NoContent()
|
|
|
72
72
|
```
|
|
73
73
|
### Error Helpers
|
|
74
74
|
```ts
|
|
75
|
-
import { BadRequest, NotFound, Unauthorized } from "api-response-kit"
|
|
75
|
+
import { BadRequest, NotFound, Unauthorized } from "@olayimika/api-response-kit"
|
|
76
76
|
|
|
77
77
|
if (!user) return NotFound("User not found")
|
|
78
78
|
if (!email) return BadRequest("Email is required")
|
|
@@ -94,7 +94,7 @@ export function getUser(id: string) {
|
|
|
94
94
|
|
|
95
95
|
## Express Adapter Example
|
|
96
96
|
```ts
|
|
97
|
-
import { sendResponse } from "api-response-kit/express"
|
|
97
|
+
import { sendResponse } from "@0layimika/api-response-kit/express"
|
|
98
98
|
|
|
99
99
|
app.get("/users/:id", (req, res) => {
|
|
100
100
|
const response = getUser(req.params.id)
|
|
@@ -103,7 +103,7 @@ app.get("/users/:id", (req, res) => {
|
|
|
103
103
|
```
|
|
104
104
|
## Custom Errors
|
|
105
105
|
```ts
|
|
106
|
-
import { CustomError } from "api-response-kit"
|
|
106
|
+
import { CustomError } from "@0layimika/api-response-kit"
|
|
107
107
|
|
|
108
108
|
return CustomError({
|
|
109
109
|
code: "PAYMENT_FAILED",
|