klaim 1.1.2 β 1.2.2
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/.github/workflows/release.yml +6 -1
- package/README.md +14 -1
- package/deno.json +38 -0
- package/deno.lock +3469 -0
- package/dist/klaim.cjs +1 -1
- package/dist/klaim.es.js +68 -46
- package/dist/klaim.umd.js +1 -1
- package/mod.ts +2 -0
- package/package.json +1 -1
- package/src/core/Hook.ts +32 -0
- package/src/core/Klaim.ts +3 -0
- package/src/index.ts +1 -0
|
@@ -6,6 +6,9 @@ on:
|
|
|
6
6
|
jobs:
|
|
7
7
|
release:
|
|
8
8
|
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
id-token: write
|
|
9
12
|
steps:
|
|
10
13
|
- name: Checkout
|
|
11
14
|
uses: actions/checkout@v2
|
|
@@ -27,7 +30,9 @@ jobs:
|
|
|
27
30
|
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
|
|
28
31
|
env:
|
|
29
32
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
30
|
-
- name:
|
|
33
|
+
- name: Publish on JSR
|
|
34
|
+
run: npx jsr publish
|
|
35
|
+
- name: Release on NPM
|
|
31
36
|
run: bun run release --ci
|
|
32
37
|
env:
|
|
33
38
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ experience.
|
|
|
6
6
|
## Links
|
|
7
7
|
|
|
8
8
|
- [NPM](https://www.npmjs.com/package/klaim)
|
|
9
|
+
- [JSR](https://jsr.io/@antharuu/klaim)
|
|
9
10
|
- [GitHub](https://github.com/antharuu/klaim)
|
|
10
11
|
|
|
11
12
|
## π Features
|
|
@@ -15,6 +16,7 @@ experience.
|
|
|
15
16
|
- **User Experience Optimization**: Focused on performance and usability for a smooth user experience.
|
|
16
17
|
- **Lightweight**: Minimal footprint for fast load times and minimal performance impact.
|
|
17
18
|
- **Middleware Support**: Easily add middleware to modify requests and responses (`before` and `after`).
|
|
19
|
+
- **Hook System**: Subscribe to hooks to monitor and react to specific events.
|
|
18
20
|
- **TypeScript Support**: Fully typed for enhanced code quality and developer experience.
|
|
19
21
|
|
|
20
22
|
## π₯ Installation
|
|
@@ -27,6 +29,9 @@ npm install klaim
|
|
|
27
29
|
|
|
28
30
|
// Using bun
|
|
29
31
|
bun add klaim
|
|
32
|
+
|
|
33
|
+
// Using deno
|
|
34
|
+
deno add @antharuu/klaim
|
|
30
35
|
```
|
|
31
36
|
|
|
32
37
|
## π Usage
|
|
@@ -34,7 +39,9 @@ bun add klaim
|
|
|
34
39
|
Hereβs a basic example to get you started:
|
|
35
40
|
|
|
36
41
|
```typescript
|
|
37
|
-
import {Api, Klaim, Registry, Route} from 'klaim';
|
|
42
|
+
import {Api, Klaim, Registry, Route, Hook} from 'klaim';
|
|
43
|
+
// OR
|
|
44
|
+
import {Api, Klaim, Registry, Route, Hook} from "@antharuu/klaim";
|
|
38
45
|
|
|
39
46
|
// Your simple Todo type
|
|
40
47
|
type Todo = {
|
|
@@ -77,6 +84,12 @@ const todo = await Klaim.hello.getTodo<Todo>({id: 1})
|
|
|
77
84
|
|
|
78
85
|
// Make a request to the "addTodo" route
|
|
79
86
|
const newTodo = await Klaim.hello.addTodo<Todo>({}, {title: "New Todo", completed: false, userId: 1})
|
|
87
|
+
|
|
88
|
+
// You can subscribe to hooks from everywhere
|
|
89
|
+
// Every time hello.getFirstTodo is called, the hook will be triggered
|
|
90
|
+
Hook.subscribe("hello.getFirstTodo", ({url}) => {
|
|
91
|
+
console.log(`Requesting ${url}`);
|
|
92
|
+
});
|
|
80
93
|
```
|
|
81
94
|
|
|
82
95
|
## π€ Contributing
|
package/deno.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@antharuu/klaim",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "Klaim is a lightweight TypeScript library designed to manage APIs and record requests, optimized for an optimal user experience.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/antharuu/klaim.git"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"typescript",
|
|
11
|
+
"api",
|
|
12
|
+
"request",
|
|
13
|
+
"user experience",
|
|
14
|
+
"optimization",
|
|
15
|
+
"lightweight"
|
|
16
|
+
],
|
|
17
|
+
"author": "antharuu",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/antharuu/klaim/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/antharuu/klaim#readme",
|
|
23
|
+
"main": "dist/klaim.cjs.js",
|
|
24
|
+
"module": "dist/klaim.es.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"exports": "./mod.ts",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "vite build",
|
|
29
|
+
"dev": "vite build --watch",
|
|
30
|
+
"test": "vitest",
|
|
31
|
+
"lint": "eslint src",
|
|
32
|
+
"lint:fix": "eslint src **/*.ts --fix",
|
|
33
|
+
"release": "dotenv release-it --"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"typescript": "^5.5.3"
|
|
37
|
+
}
|
|
38
|
+
}
|