klaim 1.0.0 β 1.0.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 +60 -8
- package/package.json +20 -1
package/README.md
CHANGED
|
@@ -1,15 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Klaim π¦
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Klaim is a lightweight TypeScript library designed to manage APIs and record requests, optimized for an optimal user
|
|
4
|
+
experience.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
## π Features
|
|
7
|
+
|
|
8
|
+
- **Efficient API Management**: Easily manage multiple APIs with streamlined integration and interaction capabilities.
|
|
9
|
+
- **Request Recording**: Seamlessly track requests for debugging and monitoring.
|
|
10
|
+
- **User Experience Optimization**: Focused on performance and usability for a smooth user experience.
|
|
11
|
+
- **Lightweight**: Minimal footprint for fast load times and minimal performance impact.
|
|
12
|
+
- **TypeScript Support**: Fully typed for enhanced code quality and developer experience.
|
|
13
|
+
|
|
14
|
+
## π₯ Installation
|
|
15
|
+
|
|
16
|
+
Install Klaim via npm:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
// Using npm
|
|
20
|
+
npm install klaim
|
|
21
|
+
|
|
22
|
+
// Using bun
|
|
23
|
+
bun add klaim
|
|
7
24
|
```
|
|
8
25
|
|
|
9
|
-
|
|
26
|
+
## π Usage
|
|
27
|
+
|
|
28
|
+
Hereβs a basic example to get you started:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import {Api, Klaim, Registry, Route} from 'klaim';
|
|
10
32
|
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
// Your simple Todo type
|
|
34
|
+
type Todo = {
|
|
35
|
+
userId: number;
|
|
36
|
+
id: number;
|
|
37
|
+
title: string;
|
|
38
|
+
completed: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// --- Basic API configuration
|
|
42
|
+
// Create a new API with the name "hello" and the base URL "https://jsonplaceholder.typicode.com/"
|
|
43
|
+
Api.create("hello", "https://jsonplaceholder.typicode.com/", () => {
|
|
44
|
+
// Define routes for the API
|
|
45
|
+
Route.get<Todo[]>("listTodos", "todos");
|
|
46
|
+
|
|
47
|
+
// You can also define routes with parameters
|
|
48
|
+
Route.get<Todo>("getTodo", "todos/[id]");
|
|
49
|
+
|
|
50
|
+
// You can also define routes in post, (put, delete, etc)
|
|
51
|
+
Route.post<Todo>("addTodo", "todos");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// --- Usage
|
|
55
|
+
// Make a request to the "listTodos" route
|
|
56
|
+
const listOfTodos = await Klaim.hello.todo<Todo>({id: 1})
|
|
57
|
+
|
|
58
|
+
// Make a request to the "getTodo" route with the parameter "id"
|
|
59
|
+
const todo = await Klaim.hello.getTodo<Todo>({id: 1})
|
|
60
|
+
|
|
61
|
+
// Make a request to the "addTodo" route
|
|
62
|
+
const newTodo = await Klaim.hello.addTodo<Todo>({}, {title: "New Todo", completed: false, userId: 1})
|
|
13
63
|
```
|
|
14
64
|
|
|
15
|
-
|
|
65
|
+
## π€ Contributing
|
|
66
|
+
|
|
67
|
+
Contributions are welcome!
|
package/package.json
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klaim",
|
|
3
|
+
"description": "Klaim is a lightweight TypeScript library designed to manage APIs and record requests, optimized for an optimal user experience.",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/antharuu/klaim.git"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [
|
|
9
|
+
"typescript",
|
|
10
|
+
"api",
|
|
11
|
+
"request",
|
|
12
|
+
"user experience",
|
|
13
|
+
"optimization",
|
|
14
|
+
"lightweight"
|
|
15
|
+
],
|
|
16
|
+
"author": "antharuu",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/antharuu/klaim/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/antharuu/klaim#readme",
|
|
3
22
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
23
|
+
"version": "1.0.1",
|
|
5
24
|
"main": "dist/klaim.cjs.js",
|
|
6
25
|
"module": "dist/klaim.es.js",
|
|
7
26
|
"types": "dist/index.d.ts",
|