@uns-kit/api 0.0.19 → 0.0.21
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/LICENSE +21 -21
- package/README.md +51 -51
- package/dist/api-interfaces.d.ts +1 -1
- package/dist/app.d.ts +0 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Aljoša Vister
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Aljoša Vister
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
# @uns-kit/api
|
|
2
|
-
|
|
3
|
-
`@uns-kit/api` exposes Express-based HTTP endpoints for UNS deployments. The plugin attaches a `createApiProxy` method to `UnsProxyProcess`, handles JWT/JWKS access control, and automatically publishes API metadata back into the Unified Namespace.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pnpm add @uns-kit/api
|
|
9
|
-
# or
|
|
10
|
-
npm install @uns-kit/api
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Make sure `@uns-kit/core` is also installed; the plugin augments its runtime types.
|
|
14
|
-
|
|
15
|
-
## Example
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process";
|
|
19
|
-
import type { UnsProxyProcessWithApi } from "@uns-kit/api";
|
|
20
|
-
import "@uns-kit/api"; // registers the plugin side-effect
|
|
21
|
-
|
|
22
|
-
async function main() {
|
|
23
|
-
const process = new UnsProxyProcess("mqtt-broker:1883", { processName: "api-gateway" }) as UnsProxyProcessWithApi;
|
|
24
|
-
|
|
25
|
-
const api = await process.createApiProxy("gateway", { jwtSecret: "super-secret" });
|
|
26
|
-
|
|
27
|
-
api.get("factory/", "status", {
|
|
28
|
-
apiDescription: "Factory status endpoint",
|
|
29
|
-
tags: ["status"],
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
api.event.on("apiGetEvent", (event) => {
|
|
33
|
-
event.res.json({ status: "ok" });
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
void main();
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Scripts
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
pnpm run typecheck
|
|
44
|
-
pnpm run build
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
`build` emits both JavaScript and type declarations to `dist/`.
|
|
48
|
-
|
|
49
|
-
## License
|
|
50
|
-
|
|
51
|
-
MIT © Aljoša Vister
|
|
1
|
+
# @uns-kit/api
|
|
2
|
+
|
|
3
|
+
`@uns-kit/api` exposes Express-based HTTP endpoints for UNS deployments. The plugin attaches a `createApiProxy` method to `UnsProxyProcess`, handles JWT/JWKS access control, and automatically publishes API metadata back into the Unified Namespace.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @uns-kit/api
|
|
9
|
+
# or
|
|
10
|
+
npm install @uns-kit/api
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Make sure `@uns-kit/core` is also installed; the plugin augments its runtime types.
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process";
|
|
19
|
+
import type { UnsProxyProcessWithApi } from "@uns-kit/api";
|
|
20
|
+
import "@uns-kit/api"; // registers the plugin side-effect
|
|
21
|
+
|
|
22
|
+
async function main() {
|
|
23
|
+
const process = new UnsProxyProcess("mqtt-broker:1883", { processName: "api-gateway" }) as UnsProxyProcessWithApi;
|
|
24
|
+
|
|
25
|
+
const api = await process.createApiProxy("gateway", { jwtSecret: "super-secret" });
|
|
26
|
+
|
|
27
|
+
api.get("factory/", "status", {
|
|
28
|
+
apiDescription: "Factory status endpoint",
|
|
29
|
+
tags: ["status"],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
api.event.on("apiGetEvent", (event) => {
|
|
33
|
+
event.res.json({ status: "ok" });
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void main();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Scripts
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pnpm run typecheck
|
|
44
|
+
pnpm run build
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`build` emits both JavaScript and type declarations to `dist/`.
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT © Aljoša Vister
|
package/dist/api-interfaces.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { IApiProxyOptions, IGetEndpointOptions, QueryParamDef } from "@uns-kit/core/uns/uns-interfaces";
|
|
1
|
+
export type { IApiProxyOptions, IGetEndpointOptions, QueryParamDef } from "@uns-kit/core/uns/uns-interfaces.js";
|
package/dist/app.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uns-kit/api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Express-powered API gateway plugin for UnsProxyProcess with JWT/JWKS support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"cookie-parser": "^1.4.7",
|
|
36
36
|
"express": "^5.1.0",
|
|
37
37
|
"multer": "^2.0.2",
|
|
38
|
-
"@uns-kit/core": "0.0.
|
|
38
|
+
"@uns-kit/core": "0.0.38"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/jsonwebtoken": "^9.0.10",
|