@alyvro/api-service 1.2.0
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 -0
- package/README.md +239 -0
- package/dist/api-BD94m-ym.d.mts +16 -0
- package/dist/api-BD94m-ym.d.ts +16 -0
- package/dist/cache-BA2IH48s.d.mts +11 -0
- package/dist/cache-BA2IH48s.d.ts +11 -0
- package/dist/chunk-CXFF7RVF.js +2 -0
- package/dist/chunk-CXFF7RVF.js.map +1 -0
- package/dist/config-Bc2nkAbT.d.mts +38 -0
- package/dist/config-Bc2nkAbT.d.ts +38 -0
- package/dist/esm/chunk-TSDIGLLM.js +2 -0
- package/dist/esm/chunk-TSDIGLLM.js.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/plugins.js +2 -0
- package/dist/esm/plugins.js.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/index.d.mts +83 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/plugins.d.mts +11 -0
- package/dist/plugins.d.ts +11 -0
- package/dist/plugins.js +2 -0
- package/dist/plugins.js.map +1 -0
- package/dist/types.d.mts +12 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alyvro
|
|
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
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# ⚡ @alyvro/api-service
|
|
2
|
+
|
|
3
|
+
[](https://socket.dev/npm/package/@alyvro/api-service/overview)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
**A minimal yet powerful service for sending HTTP requests on the client and handling them gracefully on the server. No complicated setup. Just plug in your keys — and you're ready to go.**
|
|
8
|
+
|
|
9
|
+
### 🚀 Features
|
|
10
|
+
|
|
11
|
+
- ✅ Effortless HTTP requests on the client — built on top of Axios
|
|
12
|
+
- ✅ Built-in fetch support for client-side requests
|
|
13
|
+
- ✅ Express middleware support — add it once and manage everything centrally
|
|
14
|
+
- ✅ Auto error reporting to Telegram — just provide your bot token & chat ID
|
|
15
|
+
- ✅ Fully configurable via a simple object
|
|
16
|
+
- ✅ Plugin system for extra features (Cache, Compressor, Retry, Cancel, …)
|
|
17
|
+
- ✅ Lightweight, fast, and production-ready
|
|
18
|
+
- ✅ Typed Axios response
|
|
19
|
+
|
|
20
|
+
### 📦 Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @alyvro/api-service
|
|
24
|
+
# or
|
|
25
|
+
npm install @alyvro/api-service
|
|
26
|
+
# or
|
|
27
|
+
yarn add @alyvro/api-service
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## ✨ Usage
|
|
33
|
+
|
|
34
|
+
### ➤ Client-side
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { ApiService } from "@alyvro/api-service";
|
|
38
|
+
import { cache, createAbortController } from "@alyvro/api-service/plugins";
|
|
39
|
+
|
|
40
|
+
const api = new ApiService({ api_url: "https://api.alyvro.com" });
|
|
41
|
+
|
|
42
|
+
// Example: Request with cache, compressor, and retry
|
|
43
|
+
const controller = createAbortController();
|
|
44
|
+
|
|
45
|
+
// Using Axios
|
|
46
|
+
const axiosResponse = await api.client.axios.request().post(
|
|
47
|
+
"/user",
|
|
48
|
+
{ index: "foo" },
|
|
49
|
+
{
|
|
50
|
+
secret: { body: true },
|
|
51
|
+
signal: controller.signal,
|
|
52
|
+
plugins: {
|
|
53
|
+
// cache:cache or ApiService.plugins.cache,
|
|
54
|
+
compressor: true,
|
|
55
|
+
retry: { retries: 5, retryDelay: 500, backoff: true },
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Using fetch
|
|
61
|
+
const fetchResponse = await api.client.fetch.request("/user", {
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: { index: "foo" },
|
|
64
|
+
signal: controller.signal,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Cancel request if needed
|
|
68
|
+
controller.abort();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- `cache` → stores and reuses previous responses to reduce duplicate requests (client & server safe)
|
|
72
|
+
- `compressor` → automatically compresses/decompresses payloads when supported by the server
|
|
73
|
+
- `retry` → automatic per-request retry with configurable attempts, delay, and backoff
|
|
74
|
+
- `createAbortController` → allows canceling requests on demand
|
|
75
|
+
- ⚠️ **Note:** Plugins currently only work with Axios. Fetch does **not** support Axios plugins yet.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### ➤ Server-side (Express)
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import express from "express";
|
|
83
|
+
import { ApiService } from "@alyvro/api-service";
|
|
84
|
+
|
|
85
|
+
const app = express();
|
|
86
|
+
|
|
87
|
+
const api = new ApiService({
|
|
88
|
+
url: "https://alyvro.com",
|
|
89
|
+
settings: { telegram: true }, // enables Telegram error reporting
|
|
90
|
+
middleware: {
|
|
91
|
+
skip_routers: ["/health", "/status"],
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Middleware with skip_routers option
|
|
96
|
+
app.use((req, res, next) => api.server.middleware(req, res, next));
|
|
97
|
+
|
|
98
|
+
app.get("/", (req, res) => {
|
|
99
|
+
res.json({ message: "Hello world!" });
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Middleware now supports skipping routes via `skip_routers`. Requests matching any path in this array will bypass the middleware.
|
|
104
|
+
|
|
105
|
+
All server errors will automatically be sent to your Telegram bot.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### Typed Axios Example
|
|
110
|
+
|
|
111
|
+
With this setup, you can define a strongly-typed mapping of your API endpoints and their expected responses. This allows TypeScript to infer the correct response type automatically based on the URL you pass.
|
|
112
|
+
|
|
113
|
+
#### Example
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// Define your API schema mapping endpoints to their response types
|
|
117
|
+
const apis = new ApiService({
|
|
118
|
+
url: "https://api.example.com",
|
|
119
|
+
}).client.axios.request<{
|
|
120
|
+
"/": { index: number };
|
|
121
|
+
"/auth": { success: boolean };
|
|
122
|
+
"/profile": { id: string; name: string; email: string };
|
|
123
|
+
}>();
|
|
124
|
+
|
|
125
|
+
// GET request - TypeScript infers the response type as { index: number }
|
|
126
|
+
apis.get("/").then((res) => {
|
|
127
|
+
console.log(res.data.index); // ✅ res.data.index is a number
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// POST request - TypeScript infers the response type as { success: boolean }
|
|
131
|
+
apis.post("/auth", { username: "john", password: "secret" }).then((res) => {
|
|
132
|
+
if (res.data.success) {
|
|
133
|
+
console.log("Login successful ✅");
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// PATCH request - TypeScript infers the response type as { id: string; name: string; email: string }
|
|
138
|
+
apis.patch("/profile", { name: "John Doe" }).then((res) => {
|
|
139
|
+
console.log(res.data.email); // ✅ res.data.email is a string
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// DELETE request - also fully typed
|
|
143
|
+
apis.delete("/profile").then((res) => {
|
|
144
|
+
console.log(res.data.id); // ✅ res.data.id is a string
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### Benefits
|
|
149
|
+
|
|
150
|
+
- **Type-safe endpoints**: Each endpoint URL is strongly typed, so you can’t accidentally mistype.
|
|
151
|
+
- **Automatic inference**: No need to manually annotate response types, they are inferred from the schema.
|
|
152
|
+
- **Better DX**: Autocomplete and IntelliSense show the correct response structure per endpoint.
|
|
153
|
+
|
|
154
|
+
This pattern combines the flexibility of Axios with the type-safety of a predefined API schema.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## ⚙️ Config Options
|
|
159
|
+
|
|
160
|
+
| Key | Type | Required | Description |
|
|
161
|
+
| ------------------------- | -------------------------------------- | ------------------------------------------ | -------------------------------------------------------------- |
|
|
162
|
+
| `url` | `string` | ✅ | Base URL for sending HTTP requests |
|
|
163
|
+
| `logger` | `boolean` | ❌ | Enable request/response logging (for debugging) |
|
|
164
|
+
| `auth` | `AxiosBasicCredentials` | ❌ | HTTP Basic Auth credentials (`{ username, password }`) |
|
|
165
|
+
| `env` | `ConfigEnvType` | ❌ _(if no set env variable in .env file)_ | API keys and environment secrets |
|
|
166
|
+
| `env.PRIVATE_KEY` | `string` | ✅ _(if used)_ | Your private key (used in secure requests) |
|
|
167
|
+
| `env.PUBLIC_KEY` | `string` | ✅ _(if used)_ | Your public key (used in client-side logic) |
|
|
168
|
+
| `setting` | `Partial<ConfigSettingType>` | ❌ | Additional settings for features like Telegram error reporting |
|
|
169
|
+
| `setting.telegram` | `boolean` | ✅ _(if Telegram used)_ | Telegram Bot used for error notifications |
|
|
170
|
+
| `middleware` | `Partial<ConfigMiddlewareType>` | ❌ | server **Middleware** settings |
|
|
171
|
+
| `middleware.headers` | `Partial<ConfigMiddlewareHeadersType>` | ❌ | headers names |
|
|
172
|
+
| `middleware.errors` | `Partial<ConfigMiddlewareErrorsType>` | ❌ | handlers errors |
|
|
173
|
+
| `middleware.skip_routers` | `Partial<ConfigMiddlewareErrorsType>` | ❌ | add router to not check |
|
|
174
|
+
| `middleware.powerd_by` | `string` | ❌ | add custom powerd_by |
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## 🧩 Plugins
|
|
179
|
+
|
|
180
|
+
Plugins allow extending the functionality of requests and middleware. They are configured **per-request**.
|
|
181
|
+
|
|
182
|
+
### Built-in Plugins
|
|
183
|
+
|
|
184
|
+
- **Cache**
|
|
185
|
+
Stores last response and prevents duplicate requests with identical payloads.
|
|
186
|
+
|
|
187
|
+
- **Compressor**
|
|
188
|
+
Compresses request payloads and automatically decompresses gzip responses.
|
|
189
|
+
|
|
190
|
+
- **Retry**
|
|
191
|
+
Automatically retries failed requests.
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
plugins: { retry: { retries: 5, retryDelay: 500, backoff: true } }
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
- **Cancel**
|
|
198
|
+
Allows canceling requests using `AbortController`.
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
import { createAbortController } from "@alyvro/api-service/plugins";
|
|
202
|
+
const controller = createAbortController();
|
|
203
|
+
api.get("/users", { signal: controller.signal });
|
|
204
|
+
controller.abort();
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
> ⚠️ **Note:** Plugins currently only work with Axios. Fetch does **not** support Axios plugins yet.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## 📫 Telegram Error Reporting
|
|
212
|
+
|
|
213
|
+
Errors can be automatically sent to Telegram. Just provide your bot token and chat ID in the config.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## 📘 License
|
|
218
|
+
|
|
219
|
+
MIT License
|
|
220
|
+
|
|
221
|
+
Copyright (c) 2025 Alyvro
|
|
222
|
+
|
|
223
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
224
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
225
|
+
in the Software without restriction, including without limitation the rights
|
|
226
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
227
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
228
|
+
furnished to do so, subject to the following conditions:
|
|
229
|
+
|
|
230
|
+
The above copyright notice and this permission notice shall be included in all
|
|
231
|
+
copies or substantial portions of the Software.
|
|
232
|
+
|
|
233
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
234
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
235
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
236
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
237
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
238
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
239
|
+
SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
|
|
3
|
+
type ApiResponseMapDefault = {
|
|
4
|
+
[url: string]: any;
|
|
5
|
+
};
|
|
6
|
+
type AlyvroAxiosInstance<M extends Record<string, any> = ApiResponseMapDefault> = Omit<AxiosInstance, "request" | "get" | "post" | "patch" | "delete"> & {
|
|
7
|
+
request<P extends keyof M>(config: AxiosRequestConfig & {
|
|
8
|
+
url: P;
|
|
9
|
+
}): Promise<AxiosResponse<M[P], any>>;
|
|
10
|
+
get<P extends keyof M>(url: P, config?: AxiosRequestConfig): Promise<AxiosResponse<M[P], any>>;
|
|
11
|
+
post<P extends keyof M, D = any>(url: P, data?: D, config?: AxiosRequestConfig): Promise<AxiosResponse<M[P], any>>;
|
|
12
|
+
patch<P extends keyof M, D = any>(url: P, data?: D, config?: AxiosRequestConfig): Promise<AxiosResponse<M[P], any>>;
|
|
13
|
+
delete<P extends keyof M, D = any>(url: P, config?: AxiosRequestConfig): Promise<AxiosResponse<M[P], any>>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type { ApiResponseMapDefault as A, AlyvroAxiosInstance as a };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
|
|
3
|
+
type ApiResponseMapDefault = {
|
|
4
|
+
[url: string]: any;
|
|
5
|
+
};
|
|
6
|
+
type AlyvroAxiosInstance<M extends Record<string, any> = ApiResponseMapDefault> = Omit<AxiosInstance, "request" | "get" | "post" | "patch" | "delete"> & {
|
|
7
|
+
request<P extends keyof M>(config: AxiosRequestConfig & {
|
|
8
|
+
url: P;
|
|
9
|
+
}): Promise<AxiosResponse<M[P], any>>;
|
|
10
|
+
get<P extends keyof M>(url: P, config?: AxiosRequestConfig): Promise<AxiosResponse<M[P], any>>;
|
|
11
|
+
post<P extends keyof M, D = any>(url: P, data?: D, config?: AxiosRequestConfig): Promise<AxiosResponse<M[P], any>>;
|
|
12
|
+
patch<P extends keyof M, D = any>(url: P, data?: D, config?: AxiosRequestConfig): Promise<AxiosResponse<M[P], any>>;
|
|
13
|
+
delete<P extends keyof M, D = any>(url: P, config?: AxiosRequestConfig): Promise<AxiosResponse<M[P], any>>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type { ApiResponseMapDefault as A, AlyvroAxiosInstance as a };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type ReturnFunction = {
|
|
2
|
+
get: <T>(key: string) => T | undefined;
|
|
3
|
+
set: <T>(key: string, data: T) => T;
|
|
4
|
+
clear: (key?: string | undefined) => void;
|
|
5
|
+
};
|
|
6
|
+
type CacheEntry<T> = {
|
|
7
|
+
data: T;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type { CacheEntry as C, ReturnFunction as R };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type ReturnFunction = {
|
|
2
|
+
get: <T>(key: string) => T | undefined;
|
|
3
|
+
set: <T>(key: string, data: T) => T;
|
|
4
|
+
clear: (key?: string | undefined) => void;
|
|
5
|
+
};
|
|
6
|
+
type CacheEntry<T> = {
|
|
7
|
+
data: T;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type { CacheEntry as C, ReturnFunction as R };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var a=r=>{r.interceptors.response.use(e=>e,async e=>{let t=e.config,n=_optionalChain([t, 'optionalAccess', _ => _.plugins, 'optionalAccess', _2 => _2.retry]);if(!t||!n||(t.__retryCount=t.__retryCount||0,t.__retryCount>=(_nullishCoalesce(n.retries, () => (3)))))throw e;t.__retryCount+=1;let s=n.backoff?(_nullishCoalesce(n.retryDelay, () => (1e3)))*2**(t.__retryCount-1):_nullishCoalesce(n.retryDelay, () => (1e3));if(await new Promise(i=>setTimeout(i,s)),!t.url)throw e;return r.request(t)})};var o=new Map,u= exports.c ={get:r=>_optionalChain([o, 'access', _3 => _3.get, 'call', _4 => _4(r), 'optionalAccess', _5 => _5.data]),set:(r,e)=>{let t=_optionalChain([o, 'access', _6 => _6.get, 'call', _7 => _7(r), 'optionalAccess', _8 => _8.data]);return JSON.stringify(t)===JSON.stringify(e)?t:(o.set(r,{data:e,timestamp:Date.now()}),e)},clear:r=>{r?o.delete(r):o.clear()}};exports.a = a; exports.b = o; exports.c = u;
|
|
2
|
+
//# sourceMappingURL=chunk-CXFF7RVF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\AlyvroService\\api-service\\dist\\chunk-CXFF7RVF.js"],"names":[],"mappings":"AAAA,qrBAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,iBAAC,CAAC,2BAAE,OAAO,6BAAE,OAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,kBAAC,CAAC,CAAC,OAAO,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 @@
|
|
|
1
|
+
import { AxiosBasicCredentials } from 'axios';
|
|
2
|
+
|
|
3
|
+
type ConfigEnvType = {
|
|
4
|
+
PRIVATE_KEY: string;
|
|
5
|
+
PUBLIC_KEY: string;
|
|
6
|
+
};
|
|
7
|
+
type ConfigSettingType = {
|
|
8
|
+
telegram: boolean;
|
|
9
|
+
};
|
|
10
|
+
type ConfigMiddlewareHeadersType = {
|
|
11
|
+
status: string;
|
|
12
|
+
apiKey: string;
|
|
13
|
+
bodyType: string;
|
|
14
|
+
};
|
|
15
|
+
type ConfigMiddlewareErrorsType = {
|
|
16
|
+
forbidden: string;
|
|
17
|
+
};
|
|
18
|
+
type ConfigMiddlewareType = {
|
|
19
|
+
headers: Partial<ConfigMiddlewareHeadersType>;
|
|
20
|
+
errors: Partial<ConfigMiddlewareErrorsType>;
|
|
21
|
+
skip_routers: string[];
|
|
22
|
+
powerd_by: string;
|
|
23
|
+
};
|
|
24
|
+
type ApiTypes = {
|
|
25
|
+
prefix: string;
|
|
26
|
+
data_returns: any;
|
|
27
|
+
};
|
|
28
|
+
type ConfigType = {
|
|
29
|
+
url: string;
|
|
30
|
+
logger?: boolean;
|
|
31
|
+
auth?: AxiosBasicCredentials;
|
|
32
|
+
env?: ConfigEnvType;
|
|
33
|
+
setting?: Partial<ConfigSettingType>;
|
|
34
|
+
middleware?: Partial<ConfigMiddlewareType>;
|
|
35
|
+
api_types?: ApiTypes[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type { ApiTypes as A, ConfigType as C, ConfigEnvType as a, ConfigSettingType as b, ConfigMiddlewareHeadersType as c, ConfigMiddlewareErrorsType as d, ConfigMiddlewareType as e };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AxiosBasicCredentials } from 'axios';
|
|
2
|
+
|
|
3
|
+
type ConfigEnvType = {
|
|
4
|
+
PRIVATE_KEY: string;
|
|
5
|
+
PUBLIC_KEY: string;
|
|
6
|
+
};
|
|
7
|
+
type ConfigSettingType = {
|
|
8
|
+
telegram: boolean;
|
|
9
|
+
};
|
|
10
|
+
type ConfigMiddlewareHeadersType = {
|
|
11
|
+
status: string;
|
|
12
|
+
apiKey: string;
|
|
13
|
+
bodyType: string;
|
|
14
|
+
};
|
|
15
|
+
type ConfigMiddlewareErrorsType = {
|
|
16
|
+
forbidden: string;
|
|
17
|
+
};
|
|
18
|
+
type ConfigMiddlewareType = {
|
|
19
|
+
headers: Partial<ConfigMiddlewareHeadersType>;
|
|
20
|
+
errors: Partial<ConfigMiddlewareErrorsType>;
|
|
21
|
+
skip_routers: string[];
|
|
22
|
+
powerd_by: string;
|
|
23
|
+
};
|
|
24
|
+
type ApiTypes = {
|
|
25
|
+
prefix: string;
|
|
26
|
+
data_returns: any;
|
|
27
|
+
};
|
|
28
|
+
type ConfigType = {
|
|
29
|
+
url: string;
|
|
30
|
+
logger?: boolean;
|
|
31
|
+
auth?: AxiosBasicCredentials;
|
|
32
|
+
env?: ConfigEnvType;
|
|
33
|
+
setting?: Partial<ConfigSettingType>;
|
|
34
|
+
middleware?: Partial<ConfigMiddlewareType>;
|
|
35
|
+
api_types?: ApiTypes[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type { ApiTypes as A, ConfigType as C, ConfigEnvType as a, ConfigSettingType as b, ConfigMiddlewareHeadersType as c, ConfigMiddlewareErrorsType as d, ConfigMiddlewareType as e };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=r=>{r.interceptors.response.use(e=>e,async e=>{let t=e.config,n=t?.plugins?.retry;if(!t||!n||(t.__retryCount=t.__retryCount||0,t.__retryCount>=(n.retries??3)))throw e;t.__retryCount+=1;let s=n.backoff?(n.retryDelay??1e3)*2**(t.__retryCount-1):n.retryDelay??1e3;if(await new Promise(i=>setTimeout(i,s)),!t.url)throw e;return r.request(t)})};var o=new Map,f={get:r=>o.get(r)?.data,set:(r,e)=>{let t=o.get(r)?.data;return JSON.stringify(t)===JSON.stringify(e)?t:(o.set(r,{data:e,timestamp:Date.now()}),e)},clear:r=>{r?o.delete(r):o.clear()}};export{c as a,o as b,f as c};
|
|
2
|
+
//# sourceMappingURL=chunk-TSDIGLLM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/retry.ts","../../src/plugins/cache/server.ts"],"sourcesContent":["import type { AlyvroAxiosInstance, AlyvroInternalConfig } from \"@/types/api\";\r\nimport type { AxiosError } from \"axios\";\r\n\r\nexport const retry = (instance: AlyvroAxiosInstance) => {\r\n instance.interceptors.response.use(\r\n (res) => res,\r\n async (error: AxiosError & { config?: AlyvroInternalConfig }) => {\r\n const config = error.config;\r\n const retryOpts = config?.plugins?.retry;\r\n\r\n if (!config || !retryOpts) throw error;\r\n\r\n config.__retryCount = config.__retryCount || 0;\r\n if (config.__retryCount >= (retryOpts.retries ?? 3)) throw error;\r\n\r\n config.__retryCount += 1;\r\n\r\n const delay = retryOpts.backoff\r\n ? (retryOpts.retryDelay ?? 1000) * 2 ** (config.__retryCount - 1)\r\n : retryOpts.retryDelay ?? 1000;\r\n\r\n await new Promise((res) => setTimeout(res, delay));\r\n\r\n if (!config.url) throw error;\r\n\r\n return instance.request(config as any);\r\n }\r\n );\r\n};\r\n","import type { CacheEntry, ReturnFunction } from \"@/types/cache\";\r\n\r\nexport const serverCache = new Map<string, CacheEntry<any>>();\r\n\r\nexport const serverCachePlugin: ReturnFunction = {\r\n get: <T>(key: string): T | undefined => serverCache.get(key)?.data,\r\n\r\n set: <T>(key: string, data: T): T => {\r\n const prev = serverCache.get(key)?.data;\r\n if (JSON.stringify(prev) === JSON.stringify(data)) {\r\n return prev;\r\n }\r\n serverCache.set(key, { data, timestamp: Date.now() });\r\n return data;\r\n },\r\n\r\n clear: (key?: string) => {\r\n if (key) serverCache.delete(key);\r\n else serverCache.clear();\r\n },\r\n};\r\n"],"mappings":"AAGO,IAAMA,EAASC,GAAkC,CACtDA,EAAS,aAAa,SAAS,IAC5BC,GAAQA,EACT,MAAOC,GAA0D,CAC/D,IAAMC,EAASD,EAAM,OACfE,EAAYD,GAAQ,SAAS,MAKnC,GAHI,CAACA,GAAU,CAACC,IAEhBD,EAAO,aAAeA,EAAO,cAAgB,EACzCA,EAAO,eAAiBC,EAAU,SAAW,IAAI,MAAMF,EAE3DC,EAAO,cAAgB,EAEvB,IAAME,EAAQD,EAAU,SACnBA,EAAU,YAAc,KAAQ,IAAMD,EAAO,aAAe,GAC7DC,EAAU,YAAc,IAI5B,GAFA,MAAM,IAAI,QAASH,GAAQ,WAAWA,EAAKI,CAAK,CAAC,EAE7C,CAACF,EAAO,IAAK,MAAMD,EAEvB,OAAOF,EAAS,QAAQG,CAAa,CACvC,CACF,CACF,EC1BO,IAAMG,EAAc,IAAI,IAElBC,EAAoC,CAC/C,IAASC,GAA+BF,EAAY,IAAIE,CAAG,GAAG,KAE9D,IAAK,CAAIA,EAAaC,IAAe,CACnC,IAAMC,EAAOJ,EAAY,IAAIE,CAAG,GAAG,KACnC,OAAI,KAAK,UAAUE,CAAI,IAAM,KAAK,UAAUD,CAAI,EACvCC,GAETJ,EAAY,IAAIE,EAAK,CAAE,KAAAC,EAAM,UAAW,KAAK,IAAI,CAAE,CAAC,EAC7CA,EACT,EAEA,MAAQD,GAAiB,CACnBA,EAAKF,EAAY,OAAOE,CAAG,EAC1BF,EAAY,MAAM,CACzB,CACF","names":["retry","instance","res","error","config","retryOpts","delay","serverCache","serverCachePlugin","key","data","prev"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{a as _,b as C,c as A}from"./chunk-TSDIGLLM.js";import"axios";import g from"crypto";import I from"zlib";var k=t=>{let e=process.env.PRIVATE_KEY??t?.PRIVATE_KEY,r=process.env.PUBLIC_KEY??t?.PUBLIC_KEY;if(!e||!r)throw new Error(`Please set ${e?"PUBLIC_KEY":"PRIVATE_KEY"} in env file or set in ApiService Config`);return{encryptSecureBlob:o=>{let a=g.createECDH("secp256k1");a.setPrivateKey(Buffer.from(e,"base64"));let i=a.computeSecret(Buffer.from(r,"base64")).slice(0,32),p=g.randomBytes(12),c=g.createCipheriv("aes-256-gcm",i,p),n=Buffer.concat([c.update(o,"utf8"),c.final()]),f=c.getAuthTag(),y={version:"1",iv:p.toString("base64"),tag:f.toString("base64"),encrypted:n.toString("base64"),senderPublicKey:a.getPublicKey().toString("base64")},l=JSON.stringify(y);return I.gzipSync(Buffer.from(l,"utf8")).toString("hex")},decryptSecureBlob:o=>{let a=Buffer.from(o,"hex"),s=I.gunzipSync(a),i=JSON.parse(s.toString("utf8")),p=g.createECDH("secp256k1");p.setPrivateKey(Buffer.from(e,"base64"));let n=p.computeSecret(Buffer.from(r||i.senderPublicKey,"base64")).slice(0,32),f=g.createDecipheriv("aes-256-gcm",n,Buffer.from(i.iv,"base64"));return f.setAuthTag(Buffer.from(i.tag,"base64")),Buffer.concat([f.update(Buffer.from(i.encrypted,"base64")),f.final()]).toString("utf8")}}},b=k;import M from"axios";import j from"jsonwebtoken";import{gunzipSync as Y,gzipSync as N}from"zlib";var{sign:O}=j;function B(t,e,r,o){let a=M.create({baseURL:t,auth:e});return a.interceptors.request.use(s=>{let{encryptSecureBlob:i}=b(r),p=s.secret;if(s.headers[o?.headers?.apiKey??"x-alyvro-api-key"]=O({data:"alyvro-secret-api-service"},r?.PRIVATE_KEY,{expiresIn:"10min"}),s.headers[o?.headers?.bodyType??"x-alyvro-body-type"]=p?.body?"sec":"none",s.headers[o?.headers?.status??"x-alyvro-status"]=s.status??!0,s.plugins?.compressor&&s?.data){let c=JSON.stringify(s.data);s.data=N(c),s.headers["Content-Encoding"]="gzip"}return p?.body&&s?.data&&(s.data=i(typeof s.data=="string"?s.data:JSON.stringify(s.data))),s}),a.interceptors.response.use(s=>{let i=s.data;if(s.headers["content-encoding"]==="gzip"&&Buffer.isBuffer(s.data))try{i=JSON.parse(Y(s.data).toString("utf-8"))}catch(c){console.error("Failed to decompress response",c)}let p=i;if(s.config?.plugins?.cache){let c=s.config.url;return{...s,data:s.config.plugins.cache.set(c,p)}}return{...s,data:p}}),_(a),a}var m=class extends Error{status;statusText;data;response_return_status_check;config;constructor(e,r,o,a){super(`Request failed with status ${e}`),this.status=e,this.statusText=r,this.data=o,this.config=a}};var P=null;function K(t){P=t}function T(){return P}import z from"jsonwebtoken";var{sign:L}=z;async function w(t,e){let r=T();if(!r)throw new Error("please set config");let{url:o,auth:a,env:s}=r,p={...e,headers:(()=>{let n=new Headers(e?.headers);return n.set(r.middleware?.headers?.apiKey??"x-alyvro-api-key",L({data:"alyvro-secret-api-service"},s?.PRIVATE_KEY,{expiresIn:"10min"})),n.set(r.middleware?.headers?.bodyType??"x-alyvro-body-type","none"),n.set(r.middleware?.headers?.status??"x-alyvro-status",String(e?.status??!0)),a?.username&&a?.password&&n.set("Authorization","Basic "+Buffer.from(`${a.username}:${a.password}`).toString("base64")),e?.method==="POST"&&n.set("Content-Type","application/json"),n})(),...e?.body?{body:typeof e.body=="string"?e.body:JSON.stringify(e.body)}:void 0},c=o.concat(t);if(e?.response_return){let n=await fetch(c,p);if(!e.response_return_status_check&&!n.ok){let f=await n.json();throw new m(n.status,n.statusText,f,e)}if(e.response_return_status_check&&e.response_return_status_check!==n.status){let f=await n.json();throw new m(n.status,n.statusText,f,e)}return await n.json()}return fetch(c,p)}function h(t,e){console[e].call(console,t)}import U from"axios";import{AxiosError as $}from"axios";function D(t){return t.replace(/([_\*\[\]\(\)~`>#+\-=|{}.!\\])/g,"\\$1")}var v=class{token;chat_id;obj;logger;constructor(e,r,o,a){if(!e||!r)throw new Error("Missing token or chat_id");this.token=e,this.chat_id=r,this.obj=o,this.logger=a}get request(){return U.create({baseURL:`https://api.telegram.org/bot${this.token}`})}methods={send_message:"/sendMessage"};sendMessage=async()=>{try{await this.request.post(this.methods.send_message,{chat_id:this.chat_id,text:D(`**[Server Side Error]:**
|
|
2
|
+
|
|
3
|
+
code:${this.obj.status_code}
|
|
4
|
+
method:${this.obj.method}
|
|
5
|
+
message:${this.obj.message}
|
|
6
|
+
request url: ${this.obj.originalUrl}
|
|
7
|
+
|
|
8
|
+
Time: ${new Date().toISOString()}`),parse_mode:"MarkdownV2"}),this.logger&&h("[Success Log]: Telegram Message Send","log")}catch(e){this.logger&&(e instanceof $?h(`[Error Log]: Error to send Telegram Message
|
|
9
|
+
|
|
10
|
+
Status: ${e.response?.status}
|
|
11
|
+
Data Error: ${e.response?.data}`,"error"):h(`[Error Log]: Error to send Telegram Message
|
|
12
|
+
|
|
13
|
+
Unknown Error: ${e.message}`,"error"))}}};import V from"jsonwebtoken";import{gunzipSync as q,gzipSync as F}from"zlib";var{verify:H}=V,J=async(t,e)=>{let r=process.env.TELEGRAM_TOKEN,o=process.env.TELEGRAM_CHAT_ID;if(!r||!o)throw new Error("Token or Chat ID is missing in TelegramNetwork");return await new v(r,o,{...t},e).sendMessage()},x=async(t,e,r)=>{let o=r.middleware?.powerd_by??"alyvro/api-service";r.setting?.telegram&&await J({message:r.middleware?.errors?.forbidden??"no access to this api",method:t.method,originalUrl:t.originalUrl,status_code:"403"},r.logger),e.status(403).json({message:r.middleware?.errors?.forbidden??"no access to this api",status:403,powerd_by:o})};async function S(t,e,r){let o=T();if(o?.middleware?.skip_routers?.length&&o.middleware.skip_routers.includes(t.path))return r();if(!o)throw new Error("Config no install");let a=process.env.PRIVATE_KET??o.env?.PRIVATE_KEY;if(!a||typeof a!="string")throw new Error("Please set Private Key in env file or apiService config");try{if(!t.headers[o.middleware?.headers?.status??"x-alyvro-status"]){x(t,e,o);return}let i=t.headers[o.middleware?.headers?.apiKey??"x-alyvro-api-key"],p=t.headers[o.middleware?.headers?.bodyType??"x-alyvro-body-type"];if(!i||typeof i!="string"){x(t,e,o);return}let{decryptSecureBlob:c}=b(o.env);H(i,a);let n=t.body;if(t.headers["content-encoding"]==="gzip"&&Buffer.isBuffer(n))try{n=q(n).toString("utf-8")}catch(y){console.error("Failed to decompress gzip body:",y)}if(p==="sec"){let y=c(t.body);try{y=JSON.parse(y)}catch{}t.body=y}else t.body=n;let f=e.json.bind(e);return e.json=y=>{if(t.headers["accept-encoding"]?.includes("gzip")){try{let l=F(Buffer.from(JSON.stringify(y),"utf-8"));return e.setHeader("Content-Encoding","gzip"),e.setHeader("Content-Type","application/json"),e.send(l),e}catch(l){console.error("Failed to compress response:",l)}return f()}},r()}catch{x(t,e,o);return}}var E=class{data;constructor(e){this.data=e}};var R=class extends E{constructor(e){super(e);let r=e.env?.PRIVATE_KEY??process.env.PRIVATE_KEY,o=e.env?.PUBLIC_KEY??process.env.PUBLIC_KEY;if(!r||!o)throw new Error(`Error to get ${r?"PRIVATE_KEY":"PUBLIC_KEY"}
|
|
14
|
+
please set on .env config or in ApiService options`);K({...e,env:{PRIVATE_KEY:r,PUBLIC_KEY:o}})}get client(){return{axios:{request:()=>B(this.data.url,this.data.auth,this.data.env,this.data.middleware)},fetch:{request:w}}}get server(){return{middleware:S}}static get plugins(){return{cache:{server:A}}}static get storages(){return{server:{cache:C}}}};export{R as ApiService};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/axios.d.ts","../../src/utils/enc.ts","../../src/client/api.ts","../../src/error/api-error.ts","../../src/storage/index.ts","../../src/client/fetcher.ts","../../src/utils/logger.ts","../../src/network/telegram.ts","../../src/server/middleware.ts","../../src/types/api-service.ts","../../src/config/main.ts"],"sourcesContent":["import \"axios\";\r\nimport { ReturnFunction } from \"./cache\";\r\nimport { RetryOptions } from \"./retry\";\r\n\r\ndeclare module \"axios\" {\r\n export interface AxiosRequestConfig extends ApiExteraConfigRequest {}\r\n}\r\n\r\nexport {};\r\n","import { ConfigEnvType } from \"@/types/config\";\r\nimport crypto from \"crypto\";\r\nimport zlib from \"zlib\";\r\n\r\nconst Encrypt = (env?: ConfigEnvType) => {\r\n const MY_PRIV_KEY = process.env.PRIVATE_KEY ?? env?.PRIVATE_KEY;\r\n const THEIR_PUB_KEY = process.env.PUBLIC_KEY ?? env?.PUBLIC_KEY;\r\n\r\n if (!MY_PRIV_KEY || !THEIR_PUB_KEY)\r\n throw new Error(\r\n `Please set ${\r\n !MY_PRIV_KEY ? \"PRIVATE_KEY\" : \"PUBLIC_KEY\"\r\n } in env file or set in ApiService Config`\r\n );\r\n\r\n return {\r\n encryptSecureBlob: (message: string) => {\r\n const ecdh = crypto.createECDH(\"secp256k1\");\r\n ecdh.setPrivateKey(Buffer.from(MY_PRIV_KEY!, \"base64\"));\r\n\r\n const sharedSecret = ecdh.computeSecret(\r\n Buffer.from(THEIR_PUB_KEY!, \"base64\")\r\n );\r\n const key = sharedSecret.slice(0, 32);\r\n\r\n const iv = crypto.randomBytes(12);\r\n const cipher = crypto.createCipheriv(\"aes-256-gcm\", key, iv);\r\n\r\n const encrypted = Buffer.concat([\r\n cipher.update(message, \"utf8\"),\r\n cipher.final(),\r\n ]);\r\n const tag = cipher.getAuthTag();\r\n\r\n const blob = {\r\n version: \"1\",\r\n iv: iv.toString(\"base64\"),\r\n tag: tag.toString(\"base64\"),\r\n encrypted: encrypted.toString(\"base64\"),\r\n senderPublicKey: ecdh.getPublicKey().toString(\"base64\"),\r\n };\r\n\r\n const json = JSON.stringify(blob);\r\n const gzipped = zlib.gzipSync(Buffer.from(json, \"utf8\"));\r\n\r\n return gzipped.toString(\"hex\");\r\n },\r\n\r\n decryptSecureBlob: (blobHex: string) => {\r\n const gzippedBuffer = Buffer.from(blobHex, \"hex\");\r\n const jsonBuffer = zlib.gunzipSync(gzippedBuffer);\r\n const blob = JSON.parse(jsonBuffer.toString(\"utf8\"));\r\n\r\n const ecdh = crypto.createECDH(\"secp256k1\");\r\n ecdh.setPrivateKey(Buffer.from(MY_PRIV_KEY!, \"base64\"));\r\n\r\n const sharedSecret = ecdh.computeSecret(\r\n Buffer.from(THEIR_PUB_KEY || blob.senderPublicKey, \"base64\")\r\n );\r\n const key = sharedSecret.slice(0, 32);\r\n\r\n const decipher = crypto.createDecipheriv(\r\n \"aes-256-gcm\",\r\n key,\r\n Buffer.from(blob.iv, \"base64\")\r\n );\r\n decipher.setAuthTag(Buffer.from(blob.tag, \"base64\"));\r\n\r\n const decrypted = Buffer.concat([\r\n decipher.update(Buffer.from(blob.encrypted, \"base64\")),\r\n decipher.final(),\r\n ]);\r\n\r\n return decrypted.toString(\"utf8\");\r\n },\r\n };\r\n};\r\n\r\nexport default Encrypt;\r\n","import { retry } from \"@/plugins/retry\";\r\nimport type { AlyvroAxiosInstance, ApiResponseMapDefault } from \"@/types/api\";\r\nimport type { ConfigEnvType, ConfigMiddlewareType } from \"@/types/config\";\r\nimport Encrypt from \"@/utils/enc\";\r\nimport axios, { type AxiosBasicCredentials } from \"axios\";\r\nimport jwt from \"jsonwebtoken\";\r\nimport { gunzipSync, gzipSync } from \"zlib\";\r\n\r\nconst { sign } = jwt;\r\n\r\nexport default function <M extends Record<string, any> = ApiResponseMapDefault>(\r\n base: string,\r\n auth?: AxiosBasicCredentials,\r\n env?: ConfigEnvType,\r\n config_middleware?: Partial<ConfigMiddlewareType>\r\n): AlyvroAxiosInstance<M> {\r\n const api = axios.create({\r\n baseURL: base,\r\n auth,\r\n }) as AlyvroAxiosInstance<M>;\r\n\r\n api.interceptors.request.use((config) => {\r\n const { encryptSecureBlob } = Encrypt(env);\r\n const secret = (config as any).secret;\r\n\r\n config.headers[config_middleware?.headers?.apiKey ?? \"x-alyvro-api-key\"] =\r\n sign({ data: \"alyvro-secret-api-service\" }, env?.PRIVATE_KEY!, {\r\n expiresIn: \"10min\",\r\n });\r\n\r\n config.headers[\r\n config_middleware?.headers?.bodyType ?? \"x-alyvro-body-type\"\r\n ] = secret?.body ? \"sec\" : \"none\";\r\n\r\n config.headers[config_middleware?.headers?.status ?? \"x-alyvro-status\"] =\r\n (config as any).status ?? true;\r\n\r\n if ((config as any).plugins?.compressor && config?.data) {\r\n const str = JSON.stringify(config.data);\r\n config.data = gzipSync(str);\r\n config.headers[\"Content-Encoding\"] = \"gzip\";\r\n }\r\n\r\n if (secret?.body && config?.data) {\r\n config.data = encryptSecureBlob(\r\n typeof config.data === \"string\"\r\n ? config.data\r\n : JSON.stringify(config.data)\r\n );\r\n }\r\n\r\n return config;\r\n });\r\n\r\n api.interceptors.response.use((res) => {\r\n let data = res.data;\r\n\r\n if (\r\n res.headers[\"content-encoding\"] === \"gzip\" &&\r\n Buffer.isBuffer(res.data)\r\n ) {\r\n try {\r\n data = JSON.parse(gunzipSync(res.data).toString(\"utf-8\"));\r\n } catch (error) {\r\n console.error(\"Failed to decompress response\", error);\r\n }\r\n }\r\n\r\n const parsed = data;\r\n\r\n if ((res.config as any)?.plugins?.cache) {\r\n const key = res.config.url!;\r\n return {\r\n ...res,\r\n data: (res.config as any).plugins.cache.set(key, parsed),\r\n };\r\n }\r\n\r\n return { ...res, data: parsed };\r\n });\r\n\r\n retry(api);\r\n\r\n return api;\r\n}\r\n","import type { RequestInitType } from \"@/types/fetch\";\r\n\r\nexport class ApiError<T = any> extends Error {\r\n public status: number;\r\n public statusText: string;\r\n public data: T;\r\n public response_return_status_check?: number;\r\n public config: RequestInitType;\r\n\r\n constructor(\r\n status: number,\r\n statusText: string,\r\n data: T,\r\n config: RequestInitType\r\n ) {\r\n super(`Request failed with status ${status}`);\r\n this.status = status;\r\n this.statusText = statusText;\r\n this.data = data;\r\n this.config = config;\r\n }\r\n}\r\n","// storage.ts\r\nimport { ConfigType } from \"@/types/config\";\r\n\r\nlet _configStorage: ConfigType | null = null;\r\n\r\nexport function setConfigStorage(config: ConfigType) {\r\n _configStorage = config;\r\n}\r\n\r\nexport function getConfigStorage(): ConfigType | null {\r\n return _configStorage;\r\n}\r\n","import { ApiError } from \"@/error/api-error\";\r\nimport { getConfigStorage } from \"@/storage\";\r\nimport type { RequestInitType } from \"@/types/fetch\";\r\nimport jwt from \"jsonwebtoken\";\r\n\r\nconst { sign } = jwt;\r\n\r\nexport default async function fetcher<T = unknown>(\r\n input: string,\r\n init?: RequestInitType | undefined\r\n) {\r\n const config = getConfigStorage();\r\n\r\n if (!config) throw new Error(\"please set config\");\r\n\r\n const { url, auth, env } = config;\r\n\r\n // const secret = init?.secret;\r\n\r\n const buildHeaders = (): Headers => {\r\n const headers = new Headers(init?.headers);\r\n\r\n headers.set(\r\n config.middleware?.headers?.apiKey ?? \"x-alyvro-api-key\",\r\n sign({ data: \"alyvro-secret-api-service\" }, env?.PRIVATE_KEY!, {\r\n expiresIn: \"10min\",\r\n })\r\n );\r\n headers.set(\r\n config.middleware?.headers?.bodyType ?? \"x-alyvro-body-type\",\r\n \"none\"\r\n );\r\n headers.set(\r\n config.middleware?.headers?.status ?? \"x-alyvro-status\",\r\n String(init?.status ?? true)\r\n );\r\n\r\n if (auth?.username && auth?.password) {\r\n headers.set(\r\n \"Authorization\",\r\n \"Basic \" +\r\n Buffer.from(`${auth.username}:${auth.password}`).toString(\"base64\")\r\n );\r\n }\r\n\r\n if (init?.method === \"POST\") {\r\n headers.set(\"Content-Type\", \"application/json\");\r\n }\r\n\r\n return headers;\r\n };\r\n\r\n const finalInit: RequestInitType = {\r\n ...init,\r\n headers: buildHeaders(),\r\n ...(init?.body\r\n ? {\r\n body:\r\n typeof init.body === \"string\"\r\n ? init.body\r\n : JSON.stringify(init.body),\r\n }\r\n : undefined),\r\n };\r\n\r\n const finalUrl = url.concat(input);\r\n\r\n // if (init?.plugins?.compressor && init?.body) {\r\n // const str =\r\n // typeof init.body === \"string\" ? init.body : JSON.stringify(init.body);\r\n // const compressed = gzipSync(str);\r\n\r\n // finalInit.body = new Uint8Array(compressed);\r\n // (finalInit.headers as Record<string, string>)[\"Content-Encoding\"] = \"gzip\";\r\n // }\r\n\r\n if (init?.response_return) {\r\n const res = await fetch(finalUrl, finalInit);\r\n\r\n if (!init.response_return_status_check && !res.ok) {\r\n const data = await res.json();\r\n\r\n throw new ApiError(res.status, res.statusText, data, init);\r\n }\r\n\r\n if (\r\n init.response_return_status_check &&\r\n init.response_return_status_check !== res.status\r\n ) {\r\n const data = await res.json();\r\n\r\n throw new ApiError(res.status, res.statusText, data, init);\r\n }\r\n\r\n return (await res.json()) as T;\r\n }\r\n\r\n return fetch(finalUrl, finalInit);\r\n}\r\n","export default function Logger(log: string, type: keyof Console) {\r\n console[type].call(console, log);\r\n}\r\n","import { TelegramNetworkObjectType } from \"@/types/telegram\";\r\nimport Logger from \"@/utils/logger\";\r\nimport axios from \"axios\";\r\nimport { AxiosError } from \"axios\";\r\n\r\nfunction escapeMarkdownV2(text: string): string {\r\n return text.replace(/([_\\*\\[\\]\\(\\)~`>#+\\-=|{}.!\\\\])/g, \"\\\\$1\");\r\n}\r\n\r\nexport class TelegramNetwork {\r\n private token: string;\r\n private chat_id: string;\r\n private obj: TelegramNetworkObjectType;\r\n private logger?: boolean;\r\n\r\n constructor(\r\n token: string,\r\n chat_id: string,\r\n obj: TelegramNetworkObjectType,\r\n logger?: boolean\r\n ) {\r\n if (!token || !chat_id) throw new Error(\"Missing token or chat_id\");\r\n\r\n this.token = token;\r\n this.chat_id = chat_id;\r\n this.obj = obj;\r\n this.logger = logger;\r\n }\r\n\r\n private get request() {\r\n return axios.create({\r\n baseURL: `https://api.telegram.org/bot${this.token}`,\r\n });\r\n }\r\n\r\n private methods = {\r\n send_message: \"/sendMessage\",\r\n };\r\n\r\n sendMessage = async () => {\r\n try {\r\n await this.request.post(this.methods.send_message, {\r\n chat_id: this.chat_id,\r\n text: escapeMarkdownV2(\r\n `**[Server Side Error]:**\\n\\ncode:${this.obj.status_code}\\nmethod:${\r\n this.obj.method\r\n }\\nmessage:${this.obj.message}\\nrequest url: ${\r\n this.obj.originalUrl\r\n }\\n\\nTime: ${new Date().toISOString()}`\r\n ),\r\n parse_mode: \"MarkdownV2\",\r\n });\r\n\r\n if (this.logger) {\r\n Logger(\"[Success Log]: Telegram Message Send\", \"log\");\r\n }\r\n } catch (error) {\r\n if (this.logger) {\r\n if (error instanceof AxiosError) {\r\n Logger(\r\n `[Error Log]: Error to send Telegram Message\\n\\nStatus: ${error.response?.status}\\nData Error: ${error.response?.data}`,\r\n \"error\"\r\n );\r\n } else {\r\n Logger(\r\n `[Error Log]: Error to send Telegram Message\\n\\nUnknown Error: ${\r\n (error as Error).message\r\n }`,\r\n \"error\"\r\n );\r\n }\r\n }\r\n }\r\n };\r\n}\r\n","import type { TelegramNetworkObjectType } from \"@/types/telegram\";\r\nimport type { NextFunction, Request, Response } from \"express\";\r\n\r\nimport { TelegramNetwork } from \"@/network/telegram\";\r\nimport { getConfigStorage } from \"@/storage\";\r\nimport Encrypt from \"@/utils/enc\";\r\nimport jwt from \"jsonwebtoken\";\r\nimport { gunzipSync, gzipSync } from \"zlib\";\r\nimport { ConfigType } from \"main/types\";\r\n\r\nconst { verify } = jwt;\r\n\r\nconst sendTelegramMessage = async (\r\n request_info: TelegramNetworkObjectType,\r\n logger?: boolean\r\n) => {\r\n const token = process.env.TELEGRAM_TOKEN;\r\n const chat_id = process.env.TELEGRAM_CHAT_ID;\r\n\r\n if (!token || !chat_id) {\r\n throw new Error(\"Token or Chat ID is missing in TelegramNetwork\");\r\n }\r\n\r\n const response = new TelegramNetwork(\r\n token,\r\n chat_id,\r\n {\r\n ...request_info,\r\n },\r\n logger\r\n );\r\n\r\n return await response.sendMessage();\r\n};\r\n\r\nconst sendErrorMessage = async (\r\n req: Request,\r\n res: Response,\r\n config: ConfigType\r\n) => {\r\n const powerd_by = config.middleware?.powerd_by ?? \"alyvro/api-service\";\r\n\r\n if (config.setting?.telegram) {\r\n await sendTelegramMessage(\r\n {\r\n message:\r\n config.middleware?.errors?.forbidden ?? \"no access to this api\",\r\n method: req.method,\r\n originalUrl: req.originalUrl,\r\n status_code: \"403\",\r\n },\r\n config.logger\r\n );\r\n }\r\n\r\n res.status(403).json({\r\n message: config.middleware?.errors?.forbidden ?? \"no access to this api\",\r\n status: 403,\r\n powerd_by,\r\n });\r\n};\r\n\r\nexport default async function middleware(\r\n req: Request,\r\n res: Response,\r\n next: NextFunction\r\n) {\r\n const config = getConfigStorage();\r\n\r\n if (\r\n config?.middleware?.skip_routers?.length &&\r\n config.middleware.skip_routers.includes(req.path)\r\n ) {\r\n return next();\r\n }\r\n\r\n if (!config) throw new Error(\"Config no install\");\r\n\r\n const privateKey = process.env.PRIVATE_KET ?? config.env?.PRIVATE_KEY;\r\n\r\n if (!privateKey || typeof privateKey !== \"string\")\r\n throw new Error(\"Please set Private Key in env file or apiService config\");\r\n\r\n try {\r\n const alyvroStatus =\r\n req.headers[config.middleware?.headers?.status ?? \"x-alyvro-status\"];\r\n\r\n if (!alyvroStatus) {\r\n sendErrorMessage(req, res, config);\r\n\r\n return;\r\n }\r\n\r\n const alyvroKey =\r\n req.headers[config.middleware?.headers?.apiKey ?? \"x-alyvro-api-key\"];\r\n const alyvroBodyType =\r\n req.headers[config.middleware?.headers?.bodyType ?? \"x-alyvro-body-type\"];\r\n\r\n if (!alyvroKey || typeof alyvroKey !== \"string\") {\r\n sendErrorMessage(req, res, config);\r\n return;\r\n }\r\n\r\n const { decryptSecureBlob } = Encrypt(config.env);\r\n\r\n verify(alyvroKey, privateKey);\r\n\r\n let bodyData = req.body;\r\n\r\n if (\r\n req.headers[\"content-encoding\"] === \"gzip\" &&\r\n Buffer.isBuffer(bodyData)\r\n ) {\r\n try {\r\n bodyData = gunzipSync(bodyData).toString(\"utf-8\");\r\n } catch (err) {\r\n console.error(\"Failed to decompress gzip body:\", err);\r\n }\r\n }\r\n\r\n if (alyvroBodyType === \"sec\") {\r\n let decode = decryptSecureBlob(req.body);\r\n\r\n try {\r\n decode = JSON.parse(decode);\r\n } catch (error) {}\r\n\r\n req.body = decode;\r\n } else {\r\n req.body = bodyData;\r\n }\r\n\r\n const originalJson = res.json.bind(res);\r\n res.json = (data) => {\r\n if (req.headers[\"accept-encoding\"]?.includes(\"gzip\")) {\r\n try {\r\n const compressed = gzipSync(\r\n Buffer.from(JSON.stringify(data), \"utf-8\")\r\n );\r\n res.setHeader(\"Content-Encoding\", \"gzip\");\r\n res.setHeader(\"Content-Type\", \"application/json\");\r\n res.send(compressed);\r\n return res;\r\n } catch (error) {\r\n console.error(\"Failed to compress response:\", error);\r\n }\r\n\r\n return originalJson();\r\n }\r\n };\r\n\r\n return next();\r\n } catch {\r\n sendErrorMessage(req, res, config);\r\n return;\r\n }\r\n}\r\n","import type { Request, Response, NextFunction } from \"express\";\r\nimport type { ConfigType } from \"@/types/config\";\r\nimport type { AlyvroAxiosInstance, ApiResponseMapDefault } from \"./api\";\r\n\r\nexport abstract class ApiServiceType {\r\n protected data: ConfigType;\r\n\r\n constructor(obj: ConfigType) {\r\n this.data = obj;\r\n }\r\n\r\n abstract get client(): {\r\n axios: {\r\n request: <\r\n M extends Record<string, any> = ApiResponseMapDefault\r\n >() => AlyvroAxiosInstance<M>;\r\n };\r\n fetch: {\r\n request: typeof import(\"@/client/fetcher\").default;\r\n };\r\n };\r\n\r\n abstract get server(): {\r\n middleware: (\r\n req: Request,\r\n res: Response,\r\n next: NextFunction\r\n ) => Promise<void>;\r\n };\r\n}\r\n\r\nexport interface ApiServiceTypeConstructor {\r\n new (obj: ConfigType): ApiServiceType;\r\n plugins: {\r\n cache: {\r\n server: typeof import(\"@/plugins/cache/server\").serverCachePlugin;\r\n };\r\n };\r\n}\r\n","import api from \"@/client/api\";\r\nimport fetcher from \"@/client/fetcher\";\r\nimport { serverCache, serverCachePlugin } from \"@/plugins/cache/server\";\r\nimport middleware from \"@/server/middleware\";\r\nimport { setConfigStorage } from \"@/storage\";\r\nimport { ApiResponseMapDefault } from \"@/types/api\";\r\nimport { ApiServiceType } from \"@/types/api-service\";\r\nimport type { ConfigType } from \"@/types/config\";\r\n\r\nexport class ApiService extends ApiServiceType {\r\n constructor(obj: ConfigType) {\r\n super(obj);\r\n\r\n const privateKey = obj.env?.PRIVATE_KEY ?? process.env.PRIVATE_KEY;\r\n const publicKey = obj.env?.PUBLIC_KEY ?? process.env.PUBLIC_KEY;\r\n\r\n if (!privateKey || !publicKey) {\r\n throw new Error(\r\n `Error to get ${\r\n privateKey ? \"PRIVATE_KEY\" : \"PUBLIC_KEY\"\r\n }\\nplease set on .env config or in ApiService options`\r\n );\r\n }\r\n\r\n setConfigStorage({\r\n ...obj,\r\n env: {\r\n PRIVATE_KEY: privateKey,\r\n PUBLIC_KEY: publicKey,\r\n },\r\n });\r\n }\r\n\r\n public get client() {\r\n return {\r\n axios: {\r\n request: <M extends Record<string, any> = ApiResponseMapDefault>() =>\r\n api<M>(\r\n this.data.url,\r\n this.data.auth,\r\n this.data.env,\r\n this.data.middleware\r\n ),\r\n },\r\n fetch: {\r\n request: fetcher,\r\n },\r\n };\r\n }\r\n\r\n public get server() {\r\n return {\r\n middleware,\r\n };\r\n }\r\n\r\n static get plugins() {\r\n return {\r\n cache: {\r\n server: serverCachePlugin,\r\n },\r\n };\r\n }\r\n\r\n static get storages() {\r\n return {\r\n server: {\r\n cache: serverCache,\r\n },\r\n };\r\n }\r\n}\r\n"],"mappings":"sDAAA,MAAO,QCCP,OAAOA,MAAY,SACnB,OAAOC,MAAU,OAEjB,IAAMC,EAAWC,GAAwB,CACvC,IAAMC,EAAc,QAAQ,IAAI,aAAeD,GAAK,YAC9CE,EAAgB,QAAQ,IAAI,YAAcF,GAAK,WAErD,GAAI,CAACC,GAAe,CAACC,EACnB,MAAM,IAAI,MACR,cACGD,EAA8B,aAAhB,aACjB,0CACF,EAEF,MAAO,CACL,kBAAoBE,GAAoB,CACtC,IAAMC,EAAOP,EAAO,WAAW,WAAW,EAC1CO,EAAK,cAAc,OAAO,KAAKH,EAAc,QAAQ,CAAC,EAKtD,IAAMI,EAHeD,EAAK,cACxB,OAAO,KAAKF,EAAgB,QAAQ,CACtC,EACyB,MAAM,EAAG,EAAE,EAE9BI,EAAKT,EAAO,YAAY,EAAE,EAC1BU,EAASV,EAAO,eAAe,cAAeQ,EAAKC,CAAE,EAErDE,EAAY,OAAO,OAAO,CAC9BD,EAAO,OAAOJ,EAAS,MAAM,EAC7BI,EAAO,MAAM,CACf,CAAC,EACKE,EAAMF,EAAO,WAAW,EAExBG,EAAO,CACX,QAAS,IACT,GAAIJ,EA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U,mBAAoB,MAAM,EACxCA,EAAI,UAAU,eAAgB,kBAAkB,EAChDA,EAAI,KAAKgB,CAAU,EACZhB,CACT,OAASiB,EAAO,CACd,QAAQ,MAAM,+BAAgCA,CAAK,CACrD,CAEA,OAAOH,EAAa,CACtB,CACF,EAEOV,EAAK,CACd,MAAQ,CACNN,EAAiBC,EAAKC,EAAKC,CAAM,EACjC,MACF,CACF,CCxJO,IAAeiB,EAAf,KAA8B,CACzB,KAEV,YAAYC,EAAiB,CAC3B,KAAK,KAAOA,CACd,CAoBF,ECpBO,IAAMC,EAAN,cAAyBC,CAAe,CAC7C,YAAYC,EAAiB,CAC3B,MAAMA,CAAG,EAET,IAAMC,EAAaD,EAAI,KAAK,aAAe,QAAQ,IAAI,YACjDE,EAAYF,EAAI,KAAK,YAAc,QAAQ,IAAI,WAErD,GAAI,CAACC,GAAc,CAACC,EAClB,MAAM,IAAI,MACR,gBACED,EAAa,cAAgB,YAC/B;AAAA,mDACF,EAGFE,EAAiB,CACf,GAAGH,EACH,IAAK,CACH,YAAaC,EACb,WAAYC,CACd,CACF,CAAC,CACH,CAEA,IAAW,QAAS,CAClB,MAAO,CACL,MAAO,CACL,QAAS,IACPE,EACE,KAAK,KAAK,IACV,KAAK,KAAK,KACV,KAAK,KAAK,IACV,KAAK,KAAK,UACZ,CACJ,EACA,MAAO,CACL,QAASC,CACX,CACF,CACF,CAEA,IAAW,QAAS,CAClB,MAAO,CACL,WAAAC,CACF,CACF,CAEA,WAAW,SAAU,CACnB,MAAO,CACL,MAAO,CACL,OAAQC,CACV,CACF,CACF,CAEA,WAAW,UAAW,CACpB,MAAO,CACL,OAAQ,CACN,MAAOC,CACT,CACF,CACF,CACF","names":["crypto","zlib","Encrypt","env","MY_PRIV_KEY","THEIR_PUB_KEY","message","ecdh","key","iv","cipher","encrypted","tag","blob","json","blobHex","gzippedBuffer","jsonBuffer","decipher","enc_default","axios","jwt","gunzipSync","gzipSync","sign","api_default","base","auth","env","config_middleware","api","config","encryptSecureBlob","enc_default","secret","str","res","data","error","parsed","key","retry","ApiError","status","statusText","data","config","_configStorage","setConfigStorage","config","getConfigStorage","jwt","sign","fetcher","input","init","config","getConfigStorage","url","auth","env","finalInit","headers","finalUrl","res","data","ApiError","Logger","log","type","axios","AxiosError","escapeMarkdownV2","text","TelegramNetwork","token","chat_id","obj","logger","Logger","error","jwt","gunzipSync","gzipSync","verify","sendTelegramMessage","request_info","logger","token","chat_id","TelegramNetwork","sendErrorMessage","req","res","config","powerd_by","middleware","next","getConfigStorage","privateKey","alyvroKey","alyvroBodyType","decryptSecureBlob","enc_default","bodyData","err","decode","originalJson","data","compressed","error","ApiServiceType","obj","ApiService","ApiServiceType","obj","privateKey","publicKey","setConfigStorage","api_default","fetcher","middleware","serverCachePlugin","serverCache"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/cancel.ts"],"sourcesContent":["export const createAbortController = () => {\r\n return new AbortController();\r\n};\r\n"],"mappings":"+CAAO,IAAMA,EAAwB,IAC5B,IAAI","names":["createAbortController"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { R as ReturnFunction, C as CacheEntry } from './cache-BA2IH48s.mjs';
|
|
2
|
+
import { A as ApiResponseMapDefault, a as AlyvroAxiosInstance } from './api-BD94m-ym.mjs';
|
|
3
|
+
import { Request, Response as Response$1, NextFunction } from 'express';
|
|
4
|
+
import { C as ConfigType } from './config-Bc2nkAbT.mjs';
|
|
5
|
+
import 'axios';
|
|
6
|
+
|
|
7
|
+
interface RetryOptions {
|
|
8
|
+
retries?: number;
|
|
9
|
+
retryDelay?: number;
|
|
10
|
+
backoff?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module "axios" {
|
|
14
|
+
export interface AxiosRequestConfig extends ApiExteraConfigRequest {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare global {
|
|
18
|
+
type ApiExteraConfigRequest = {
|
|
19
|
+
secret?: Partial<{
|
|
20
|
+
body: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
status?: boolean;
|
|
23
|
+
plugins?: Partial<{
|
|
24
|
+
cache: ReturnFunction;
|
|
25
|
+
compressor: boolean;
|
|
26
|
+
retry: Partial<RetryOptions>;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type RequestInitType = Readonly<{
|
|
32
|
+
response_return?: boolean;
|
|
33
|
+
response_return_status_check?: number;
|
|
34
|
+
status?: boolean;
|
|
35
|
+
body?: any;
|
|
36
|
+
}> & RequestInit;
|
|
37
|
+
|
|
38
|
+
declare function fetcher<T = unknown>(input: string, init?: RequestInitType | undefined): Promise<T | Response>;
|
|
39
|
+
|
|
40
|
+
declare function middleware(req: Request, res: Response$1, next: NextFunction): Promise<void>;
|
|
41
|
+
|
|
42
|
+
declare abstract class ApiServiceType {
|
|
43
|
+
protected data: ConfigType;
|
|
44
|
+
constructor(obj: ConfigType);
|
|
45
|
+
abstract get client(): {
|
|
46
|
+
axios: {
|
|
47
|
+
request: <M extends Record<string, any> = ApiResponseMapDefault>() => AlyvroAxiosInstance<M>;
|
|
48
|
+
};
|
|
49
|
+
fetch: {
|
|
50
|
+
request: typeof fetcher;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
abstract get server(): {
|
|
54
|
+
middleware: (req: Request, res: Response$1, next: NextFunction) => Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare class ApiService extends ApiServiceType {
|
|
59
|
+
constructor(obj: ConfigType);
|
|
60
|
+
get client(): {
|
|
61
|
+
axios: {
|
|
62
|
+
request: <M extends Record<string, any> = ApiResponseMapDefault>() => AlyvroAxiosInstance<M>;
|
|
63
|
+
};
|
|
64
|
+
fetch: {
|
|
65
|
+
request: typeof fetcher;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
get server(): {
|
|
69
|
+
middleware: typeof middleware;
|
|
70
|
+
};
|
|
71
|
+
static get plugins(): {
|
|
72
|
+
cache: {
|
|
73
|
+
server: ReturnFunction;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
static get storages(): {
|
|
77
|
+
server: {
|
|
78
|
+
cache: Map<string, CacheEntry<any>>;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { ApiService };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { R as ReturnFunction, C as CacheEntry } from './cache-BA2IH48s.js';
|
|
2
|
+
import { A as ApiResponseMapDefault, a as AlyvroAxiosInstance } from './api-BD94m-ym.js';
|
|
3
|
+
import { Request, Response as Response$1, NextFunction } from 'express';
|
|
4
|
+
import { C as ConfigType } from './config-Bc2nkAbT.js';
|
|
5
|
+
import 'axios';
|
|
6
|
+
|
|
7
|
+
interface RetryOptions {
|
|
8
|
+
retries?: number;
|
|
9
|
+
retryDelay?: number;
|
|
10
|
+
backoff?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module "axios" {
|
|
14
|
+
export interface AxiosRequestConfig extends ApiExteraConfigRequest {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare global {
|
|
18
|
+
type ApiExteraConfigRequest = {
|
|
19
|
+
secret?: Partial<{
|
|
20
|
+
body: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
status?: boolean;
|
|
23
|
+
plugins?: Partial<{
|
|
24
|
+
cache: ReturnFunction;
|
|
25
|
+
compressor: boolean;
|
|
26
|
+
retry: Partial<RetryOptions>;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type RequestInitType = Readonly<{
|
|
32
|
+
response_return?: boolean;
|
|
33
|
+
response_return_status_check?: number;
|
|
34
|
+
status?: boolean;
|
|
35
|
+
body?: any;
|
|
36
|
+
}> & RequestInit;
|
|
37
|
+
|
|
38
|
+
declare function fetcher<T = unknown>(input: string, init?: RequestInitType | undefined): Promise<T | Response>;
|
|
39
|
+
|
|
40
|
+
declare function middleware(req: Request, res: Response$1, next: NextFunction): Promise<void>;
|
|
41
|
+
|
|
42
|
+
declare abstract class ApiServiceType {
|
|
43
|
+
protected data: ConfigType;
|
|
44
|
+
constructor(obj: ConfigType);
|
|
45
|
+
abstract get client(): {
|
|
46
|
+
axios: {
|
|
47
|
+
request: <M extends Record<string, any> = ApiResponseMapDefault>() => AlyvroAxiosInstance<M>;
|
|
48
|
+
};
|
|
49
|
+
fetch: {
|
|
50
|
+
request: typeof fetcher;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
abstract get server(): {
|
|
54
|
+
middleware: (req: Request, res: Response$1, next: NextFunction) => Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare class ApiService extends ApiServiceType {
|
|
59
|
+
constructor(obj: ConfigType);
|
|
60
|
+
get client(): {
|
|
61
|
+
axios: {
|
|
62
|
+
request: <M extends Record<string, any> = ApiResponseMapDefault>() => AlyvroAxiosInstance<M>;
|
|
63
|
+
};
|
|
64
|
+
fetch: {
|
|
65
|
+
request: typeof fetcher;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
get server(): {
|
|
69
|
+
middleware: typeof middleware;
|
|
70
|
+
};
|
|
71
|
+
static get plugins(): {
|
|
72
|
+
cache: {
|
|
73
|
+
server: ReturnFunction;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
static get storages(): {
|
|
77
|
+
server: {
|
|
78
|
+
cache: Map<string, CacheEntry<any>>;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { ApiService };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var _chunkCXFF7RVFjs = require('./chunk-CXFF7RVF.js');var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);var _zlib = require('zlib'); var _zlib2 = _interopRequireDefault(_zlib);var K=t=>{let e=_nullishCoalesce(process.env.PRIVATE_KEY, () => (_optionalChain([t, 'optionalAccess', _2 => _2.PRIVATE_KEY]))),r=_nullishCoalesce(process.env.PUBLIC_KEY, () => (_optionalChain([t, 'optionalAccess', _3 => _3.PUBLIC_KEY])));if(!e||!r)throw new Error(`Please set ${e?"PUBLIC_KEY":"PRIVATE_KEY"} in env file or set in ApiService Config`);return{encryptSecureBlob:o=>{let a=_crypto2.default.createECDH("secp256k1");a.setPrivateKey(Buffer.from(e,"base64"));let i=a.computeSecret(Buffer.from(r,"base64")).slice(0,32),p=_crypto2.default.randomBytes(12),c=_crypto2.default.createCipheriv("aes-256-gcm",i,p),n=Buffer.concat([c.update(o,"utf8"),c.final()]),u=c.getAuthTag(),f={version:"1",iv:p.toString("base64"),tag:u.toString("base64"),encrypted:n.toString("base64"),senderPublicKey:a.getPublicKey().toString("base64")},y=JSON.stringify(f);return _zlib2.default.gzipSync(Buffer.from(y,"utf8")).toString("hex")},decryptSecureBlob:o=>{let a=Buffer.from(o,"hex"),s=_zlib2.default.gunzipSync(a),i=JSON.parse(s.toString("utf8")),p=_crypto2.default.createECDH("secp256k1");p.setPrivateKey(Buffer.from(e,"base64"));let n=p.computeSecret(Buffer.from(r||i.senderPublicKey,"base64")).slice(0,32),u=_crypto2.default.createDecipheriv("aes-256-gcm",n,Buffer.from(i.iv,"base64"));return u.setAuthTag(Buffer.from(i.tag,"base64")),Buffer.concat([u.update(Buffer.from(i.encrypted,"base64")),u.final()]).toString("utf8")}}},h=K;var _jsonwebtoken = require('jsonwebtoken'); var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken);var{sign:N}=_jsonwebtoken2.default;function I(t,e,r,o){let a=_axios2.default.create({baseURL:t,auth:e});return a.interceptors.request.use(s=>{let{encryptSecureBlob:i}=h(r),p=s.secret;if(s.headers[_nullishCoalesce(_optionalChain([o, 'optionalAccess', _4 => _4.headers, 'optionalAccess', _5 => _5.apiKey]), () => ("x-alyvro-api-key"))]=N({data:"alyvro-secret-api-service"},_optionalChain([r, 'optionalAccess', _6 => _6.PRIVATE_KEY]),{expiresIn:"10min"}),s.headers[_nullishCoalesce(_optionalChain([o, 'optionalAccess', _7 => _7.headers, 'optionalAccess', _8 => _8.bodyType]), () => ("x-alyvro-body-type"))]=_optionalChain([p, 'optionalAccess', _9 => _9.body])?"sec":"none",s.headers[_nullishCoalesce(_optionalChain([o, 'optionalAccess', _10 => _10.headers, 'optionalAccess', _11 => _11.status]), () => ("x-alyvro-status"))]=_nullishCoalesce(s.status, () => (!0)),_optionalChain([s, 'access', _12 => _12.plugins, 'optionalAccess', _13 => _13.compressor])&&_optionalChain([s, 'optionalAccess', _14 => _14.data])){let c=JSON.stringify(s.data);s.data=_zlib.gzipSync.call(void 0, c),s.headers["Content-Encoding"]="gzip"}return _optionalChain([p, 'optionalAccess', _15 => _15.body])&&_optionalChain([s, 'optionalAccess', _16 => _16.data])&&(s.data=i(typeof s.data=="string"?s.data:JSON.stringify(s.data))),s}),a.interceptors.response.use(s=>{let i=s.data;if(s.headers["content-encoding"]==="gzip"&&Buffer.isBuffer(s.data))try{i=JSON.parse(_zlib.gunzipSync.call(void 0, s.data).toString("utf-8"))}catch(c){console.error("Failed to decompress response",c)}let p=i;if(_optionalChain([s, 'access', _17 => _17.config, 'optionalAccess', _18 => _18.plugins, 'optionalAccess', _19 => _19.cache])){let c=s.config.url;return{...s,data:s.config.plugins.cache.set(c,p)}}return{...s,data:p}}),_chunkCXFF7RVFjs.a.call(void 0, a),a}var g=class extends Error{constructor(e,r,o,a){super(`Request failed with status ${e}`),this.status=e,this.statusText=r,this.data=o,this.config=a}};var B=null;function P(t){B=t}function b(){return B}var{sign:z}=_jsonwebtoken2.default;async function E(t,e){let r=b();if(!r)throw new Error("please set config");let{url:o,auth:a,env:s}=r,p={...e,headers:(()=>{let n=new Headers(_optionalChain([e, 'optionalAccess', _20 => _20.headers]));return n.set(_nullishCoalesce(_optionalChain([r, 'access', _21 => _21.middleware, 'optionalAccess', _22 => _22.headers, 'optionalAccess', _23 => _23.apiKey]), () => ("x-alyvro-api-key")),z({data:"alyvro-secret-api-service"},_optionalChain([s, 'optionalAccess', _24 => _24.PRIVATE_KEY]),{expiresIn:"10min"})),n.set(_nullishCoalesce(_optionalChain([r, 'access', _25 => _25.middleware, 'optionalAccess', _26 => _26.headers, 'optionalAccess', _27 => _27.bodyType]), () => ("x-alyvro-body-type")),"none"),n.set(_nullishCoalesce(_optionalChain([r, 'access', _28 => _28.middleware, 'optionalAccess', _29 => _29.headers, 'optionalAccess', _30 => _30.status]), () => ("x-alyvro-status")),String(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _31 => _31.status]), () => (!0)))),_optionalChain([a, 'optionalAccess', _32 => _32.username])&&_optionalChain([a, 'optionalAccess', _33 => _33.password])&&n.set("Authorization","Basic "+Buffer.from(`${a.username}:${a.password}`).toString("base64")),_optionalChain([e, 'optionalAccess', _34 => _34.method])==="POST"&&n.set("Content-Type","application/json"),n})(),..._optionalChain([e, 'optionalAccess', _35 => _35.body])?{body:typeof e.body=="string"?e.body:JSON.stringify(e.body)}:void 0},c=o.concat(t);if(_optionalChain([e, 'optionalAccess', _36 => _36.response_return])){let n=await fetch(c,p);if(!e.response_return_status_check&&!n.ok){let u=await n.json();throw new g(n.status,n.statusText,u,e)}if(e.response_return_status_check&&e.response_return_status_check!==n.status){let u=await n.json();throw new g(n.status,n.statusText,u,e)}return await n.json()}return fetch(c,p)}function m(t,e){console[e].call(console,t)}function $(t){return t.replace(/([_\*\[\]\(\)~`>#+\-=|{}.!\\])/g,"\\$1")}var T= (_class =class{constructor(e,r,o,a){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);if(!e||!r)throw new Error("Missing token or chat_id");this.token=e,this.chat_id=r,this.obj=o,this.logger=a}get request(){return _axios2.default.create({baseURL:`https://api.telegram.org/bot${this.token}`})}__init() {this.methods={send_message:"/sendMessage"}}__init2() {this.sendMessage=async()=>{try{await this.request.post(this.methods.send_message,{chat_id:this.chat_id,text:$(`**[Server Side Error]:**
|
|
2
|
+
|
|
3
|
+
code:${this.obj.status_code}
|
|
4
|
+
method:${this.obj.method}
|
|
5
|
+
message:${this.obj.message}
|
|
6
|
+
request url: ${this.obj.originalUrl}
|
|
7
|
+
|
|
8
|
+
Time: ${new Date().toISOString()}`),parse_mode:"MarkdownV2"}),this.logger&&m("[Success Log]: Telegram Message Send","log")}catch(e){this.logger&&(e instanceof _axios.AxiosError?m(`[Error Log]: Error to send Telegram Message
|
|
9
|
+
|
|
10
|
+
Status: ${_optionalChain([e, 'access', _41 => _41.response, 'optionalAccess', _42 => _42.status])}
|
|
11
|
+
Data Error: ${_optionalChain([e, 'access', _43 => _43.response, 'optionalAccess', _44 => _44.data])}`,"error"):m(`[Error Log]: Error to send Telegram Message
|
|
12
|
+
|
|
13
|
+
Unknown Error: ${e.message}`,"error"))}}}}, _class);var{verify:F}=_jsonwebtoken2.default,H=async(t,e)=>{let r=process.env.TELEGRAM_TOKEN,o=process.env.TELEGRAM_CHAT_ID;if(!r||!o)throw new Error("Token or Chat ID is missing in TelegramNetwork");return await new T(r,o,{...t},e).sendMessage()},w=async(t,e,r)=>{let o=_nullishCoalesce(_optionalChain([r, 'access', _45 => _45.middleware, 'optionalAccess', _46 => _46.powerd_by]), () => ("alyvro/api-service"));_optionalChain([r, 'access', _47 => _47.setting, 'optionalAccess', _48 => _48.telegram])&&await H({message:_nullishCoalesce(_optionalChain([r, 'access', _49 => _49.middleware, 'optionalAccess', _50 => _50.errors, 'optionalAccess', _51 => _51.forbidden]), () => ("no access to this api")),method:t.method,originalUrl:t.originalUrl,status_code:"403"},r.logger),e.status(403).json({message:_nullishCoalesce(_optionalChain([r, 'access', _52 => _52.middleware, 'optionalAccess', _53 => _53.errors, 'optionalAccess', _54 => _54.forbidden]), () => ("no access to this api")),status:403,powerd_by:o})};async function x(t,e,r){let o=b();if(_optionalChain([o, 'optionalAccess', _55 => _55.middleware, 'optionalAccess', _56 => _56.skip_routers, 'optionalAccess', _57 => _57.length])&&o.middleware.skip_routers.includes(t.path))return r();if(!o)throw new Error("Config no install");let a=_nullishCoalesce(process.env.PRIVATE_KET, () => (_optionalChain([o, 'access', _58 => _58.env, 'optionalAccess', _59 => _59.PRIVATE_KEY])));if(!a||typeof a!="string")throw new Error("Please set Private Key in env file or apiService config");try{if(!t.headers[_nullishCoalesce(_optionalChain([o, 'access', _60 => _60.middleware, 'optionalAccess', _61 => _61.headers, 'optionalAccess', _62 => _62.status]), () => ("x-alyvro-status"))]){w(t,e,o);return}let i=t.headers[_nullishCoalesce(_optionalChain([o, 'access', _63 => _63.middleware, 'optionalAccess', _64 => _64.headers, 'optionalAccess', _65 => _65.apiKey]), () => ("x-alyvro-api-key"))],p=t.headers[_nullishCoalesce(_optionalChain([o, 'access', _66 => _66.middleware, 'optionalAccess', _67 => _67.headers, 'optionalAccess', _68 => _68.bodyType]), () => ("x-alyvro-body-type"))];if(!i||typeof i!="string"){w(t,e,o);return}let{decryptSecureBlob:c}=h(o.env);F(i,a);let n=t.body;if(t.headers["content-encoding"]==="gzip"&&Buffer.isBuffer(n))try{n=_zlib.gunzipSync.call(void 0, n).toString("utf-8")}catch(f){console.error("Failed to decompress gzip body:",f)}if(p==="sec"){let f=c(t.body);try{f=JSON.parse(f)}catch (e2){}t.body=f}else t.body=n;let u=e.json.bind(e);return e.json=f=>{if(_optionalChain([t, 'access', _69 => _69.headers, 'access', _70 => _70["accept-encoding"], 'optionalAccess', _71 => _71.includes, 'call', _72 => _72("gzip")])){try{let y=_zlib.gzipSync.call(void 0, Buffer.from(JSON.stringify(f),"utf-8"));return e.setHeader("Content-Encoding","gzip"),e.setHeader("Content-Type","application/json"),e.send(y),e}catch(y){console.error("Failed to compress response:",y)}return u()}},r()}catch (e3){w(t,e,o);return}}var v=class{constructor(e){this.data=e}};var S=class extends v{constructor(e){super(e);let r=_nullishCoalesce(_optionalChain([e, 'access', _73 => _73.env, 'optionalAccess', _74 => _74.PRIVATE_KEY]), () => (process.env.PRIVATE_KEY)),o=_nullishCoalesce(_optionalChain([e, 'access', _75 => _75.env, 'optionalAccess', _76 => _76.PUBLIC_KEY]), () => (process.env.PUBLIC_KEY));if(!r||!o)throw new Error(`Error to get ${r?"PRIVATE_KEY":"PUBLIC_KEY"}
|
|
14
|
+
please set on .env config or in ApiService options`);P({...e,env:{PRIVATE_KEY:r,PUBLIC_KEY:o}})}get client(){return{axios:{request:()=>I(this.data.url,this.data.auth,this.data.env,this.data.middleware)},fetch:{request:E}}}get server(){return{middleware:x}}static get plugins(){return{cache:{server:_chunkCXFF7RVFjs.c}}}static get storages(){return{server:{cache:_chunkCXFF7RVFjs.b}}}};exports.ApiService = S;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\AlyvroService\\api-service\\dist\\index.js"],"names":[],"mappings":"AAAA,m1BAAqD,4EAAc,gFAAsB,wEAAoB,IAAK,CAAC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E,CAAC,CAAC,CAAA;AACA;AACA,KAAA;AACA,OAAA;AACA,QAAA;AACA,aAAA;AACA;AACA,MAAA;AACA;AACA,QAAA;AACA,YAAA;AACA;AACA,eAAA;AACA,kDAAA","file":"D:\\AlyvroService\\api-service\\dist\\index.js","sourcesContent":[null]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"node_modules/.pnpm/tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7/node_modules/tsup/assets/cjs_shims.js":{"bytes":498,"imports":[],"format":"esm"},"src/types/axios.d.ts":{"bytes":219,"imports":[{"path":"axios","kind":"import-statement","external":true},{"path":"./cache","kind":"import-statement","external":true},{"path":"./retry","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/types/global.d.ts":{"bytes":379,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugins/retry.ts":{"bytes":934,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/utils/enc.ts":{"bytes":2446,"imports":[{"path":"@/types/config","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/client/api.ts":{"bytes":2443,"imports":[{"path":"src/plugins/retry.ts","kind":"import-statement","original":"@/plugins/retry"},{"path":"src/utils/enc.ts","kind":"import-statement","original":"@/utils/enc"},{"path":"axios","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/error/api-error.ts":{"bytes":550,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/storage/index.ts":{"bytes":287,"imports":[{"path":"@/types/config","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/client/fetcher.ts":{"bytes":2617,"imports":[{"path":"src/error/api-error.ts","kind":"import-statement","original":"@/error/api-error"},{"path":"src/storage/index.ts","kind":"import-statement","original":"@/storage"},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugins/cache/server.ts":{"bytes":628,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/utils/logger.ts":{"bytes":108,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/network/telegram.ts":{"bytes":2061,"imports":[{"path":"@/types/telegram","kind":"import-statement","external":true},{"path":"src/utils/logger.ts","kind":"import-statement","original":"@/utils/logger"},{"path":"axios","kind":"import-statement","external":true},{"path":"axios","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/server/middleware.ts":{"bytes":3994,"imports":[{"path":"src/network/telegram.ts","kind":"import-statement","original":"@/network/telegram"},{"path":"src/storage/index.ts","kind":"import-statement","original":"@/storage"},{"path":"src/utils/enc.ts","kind":"import-statement","original":"@/utils/enc"},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"main/types","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/types/api-service.ts":{"bytes":945,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/config/main.ts":{"bytes":1688,"imports":[{"path":"src/client/api.ts","kind":"import-statement","original":"@/client/api"},{"path":"src/client/fetcher.ts","kind":"import-statement","original":"@/client/fetcher"},{"path":"src/plugins/cache/server.ts","kind":"import-statement","original":"@/plugins/cache/server"},{"path":"src/server/middleware.ts","kind":"import-statement","original":"@/server/middleware"},{"path":"src/storage/index.ts","kind":"import-statement","original":"@/storage"},{"path":"@/types/api","kind":"import-statement","external":true},{"path":"src/types/api-service.ts","kind":"import-statement","original":"@/types/api-service"},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"main/index.ts":{"bytes":138,"imports":[{"path":"src/types/axios.d.ts","kind":"import-statement","original":"src/types/axios.d.ts"},{"path":"src/types/global.d.ts","kind":"import-statement","original":"src/types/global.d.ts"},{"path":"src/config/main.ts","kind":"import-statement","original":"@/config/main"},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugins/cancel.ts":{"bytes":83,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugins/index.ts":{"bytes":147,"imports":[{"path":"src/plugins/cancel.ts","kind":"import-statement","original":"./cancel"},{"path":"src/plugins/retry.ts","kind":"import-statement","original":"./retry"},{"path":"src/plugins/cache/server.ts","kind":"import-statement","original":"./cache/server"},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"main/plugins.ts":{"bytes":28,"imports":[{"path":"src/plugins/index.ts","kind":"import-statement","original":"@/plugins"},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"main/types.ts":{"bytes":119,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":28718},"dist/index.js":{"imports":[{"path":"dist/chunk-CXFF7RVF.js","kind":"import-statement"},{"path":"axios","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"axios","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"axios","kind":"import-statement","external":true},{"path":"axios","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true}],"exports":["ApiService"],"entryPoint":"main/index.ts","inputs":{"src/types/axios.d.ts":{"bytesInOutput":14},"src/utils/enc.ts":{"bytesInOutput":1216},"src/client/api.ts":{"bytesInOutput":1064},"src/error/api-error.ts":{"bytesInOutput":207},"src/storage/index.ts":{"bytesInOutput":51},"src/client/fetcher.ts":{"bytesInOutput":1086},"src/utils/logger.ts":{"bytesInOutput":43},"src/network/telegram.ts":{"bytesInOutput":1041},"src/server/middleware.ts":{"bytesInOutput":1854},"src/types/api-service.ts":{"bytesInOutput":46},"src/config/main.ts":{"bytesInOutput":563},"main/index.ts":{"bytesInOutput":0}},"bytes":7264},"dist/plugins.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":261},"dist/plugins.js":{"imports":[{"path":"dist/chunk-CXFF7RVF.js","kind":"import-statement"}],"exports":["cache","createAbortController","retry"],"entryPoint":"main/plugins.ts","inputs":{"src/plugins/cancel.ts":{"bytesInOutput":30},"src/plugins/index.ts":{"bytesInOutput":0},"main/plugins.ts":{"bytesInOutput":0}},"bytes":135},"dist/chunk-CXFF7RVF.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":2736},"dist/chunk-CXFF7RVF.js":{"imports":[],"exports":["a","b","c"],"inputs":{"src/plugins/retry.ts":{"bytesInOutput":346},"src/plugins/cache/server.ts":{"bytesInOutput":199}},"bytes":570},"dist/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/types.js":{"imports":[],"exports":[],"entryPoint":"main/types.ts","inputs":{"main/types.ts":{"bytesInOutput":0}},"bytes":0}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"node_modules/.pnpm/tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7/node_modules/tsup/assets/esm_shims.js":{"bytes":322,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"url","kind":"import-statement","external":true}],"format":"esm"},"src/types/axios.d.ts":{"bytes":219,"imports":[{"path":"axios","kind":"import-statement","external":true},{"path":"./cache","kind":"import-statement","external":true},{"path":"./retry","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/types/global.d.ts":{"bytes":379,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugins/retry.ts":{"bytes":934,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/utils/enc.ts":{"bytes":2446,"imports":[{"path":"@/types/config","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/client/api.ts":{"bytes":2443,"imports":[{"path":"src/plugins/retry.ts","kind":"import-statement","original":"@/plugins/retry"},{"path":"src/utils/enc.ts","kind":"import-statement","original":"@/utils/enc"},{"path":"axios","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/error/api-error.ts":{"bytes":550,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/storage/index.ts":{"bytes":287,"imports":[{"path":"@/types/config","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/client/fetcher.ts":{"bytes":2617,"imports":[{"path":"src/error/api-error.ts","kind":"import-statement","original":"@/error/api-error"},{"path":"src/storage/index.ts","kind":"import-statement","original":"@/storage"},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugins/cache/server.ts":{"bytes":628,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/utils/logger.ts":{"bytes":108,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/network/telegram.ts":{"bytes":2061,"imports":[{"path":"@/types/telegram","kind":"import-statement","external":true},{"path":"src/utils/logger.ts","kind":"import-statement","original":"@/utils/logger"},{"path":"axios","kind":"import-statement","external":true},{"path":"axios","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/server/middleware.ts":{"bytes":3994,"imports":[{"path":"src/network/telegram.ts","kind":"import-statement","original":"@/network/telegram"},{"path":"src/storage/index.ts","kind":"import-statement","original":"@/storage"},{"path":"src/utils/enc.ts","kind":"import-statement","original":"@/utils/enc"},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"main/types","kind":"import-statement","external":true},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/types/api-service.ts":{"bytes":945,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/config/main.ts":{"bytes":1688,"imports":[{"path":"src/client/api.ts","kind":"import-statement","original":"@/client/api"},{"path":"src/client/fetcher.ts","kind":"import-statement","original":"@/client/fetcher"},{"path":"src/plugins/cache/server.ts","kind":"import-statement","original":"@/plugins/cache/server"},{"path":"src/server/middleware.ts","kind":"import-statement","original":"@/server/middleware"},{"path":"src/storage/index.ts","kind":"import-statement","original":"@/storage"},{"path":"@/types/api","kind":"import-statement","external":true},{"path":"src/types/api-service.ts","kind":"import-statement","original":"@/types/api-service"},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"main/index.ts":{"bytes":138,"imports":[{"path":"src/types/axios.d.ts","kind":"import-statement","original":"src/types/axios.d.ts"},{"path":"src/types/global.d.ts","kind":"import-statement","original":"src/types/global.d.ts"},{"path":"src/config/main.ts","kind":"import-statement","original":"@/config/main"},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugins/cancel.ts":{"bytes":83,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugins/index.ts":{"bytes":147,"imports":[{"path":"src/plugins/cancel.ts","kind":"import-statement","original":"./cancel"},{"path":"src/plugins/retry.ts","kind":"import-statement","original":"./retry"},{"path":"src/plugins/cache/server.ts","kind":"import-statement","original":"./cache/server"},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"main/plugins.ts":{"bytes":28,"imports":[{"path":"src/plugins/index.ts","kind":"import-statement","original":"@/plugins"},{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"},"main/types.ts":{"bytes":119,"imports":[{"path":"D:\\AlyvroService\\api-service\\node_modules\\.pnpm\\tsup@8.5.0_jiti@2.6.0_postc_2ad68514a1e19d33b0c0d1d88e6de8b7\\node_modules\\tsup\\assets\\esm_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/esm/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":28751},"dist/esm/index.js":{"imports":[{"path":"dist/esm/chunk-TSDIGLLM.js","kind":"import-statement"},{"path":"axios","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"axios","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"axios","kind":"import-statement","external":true},{"path":"axios","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"zlib","kind":"import-statement","external":true}],"exports":["ApiService"],"entryPoint":"main/index.ts","inputs":{"src/types/axios.d.ts":{"bytesInOutput":14},"src/utils/enc.ts":{"bytesInOutput":1216},"src/client/api.ts":{"bytesInOutput":1064},"src/error/api-error.ts":{"bytesInOutput":207},"src/storage/index.ts":{"bytesInOutput":51},"src/client/fetcher.ts":{"bytesInOutput":1086},"src/utils/logger.ts":{"bytesInOutput":43},"src/network/telegram.ts":{"bytesInOutput":1041},"src/server/middleware.ts":{"bytesInOutput":1854},"src/types/api-service.ts":{"bytesInOutput":46},"src/config/main.ts":{"bytesInOutput":563},"main/index.ts":{"bytesInOutput":0}},"bytes":7264},"dist/esm/plugins.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":264},"dist/esm/plugins.js":{"imports":[{"path":"dist/esm/chunk-TSDIGLLM.js","kind":"import-statement"}],"exports":["cache","createAbortController","retry"],"entryPoint":"main/plugins.ts","inputs":{"src/plugins/cancel.ts":{"bytesInOutput":30},"src/plugins/index.ts":{"bytesInOutput":0},"main/plugins.ts":{"bytesInOutput":0}},"bytes":135},"dist/esm/chunk-TSDIGLLM.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":2742},"dist/esm/chunk-TSDIGLLM.js":{"imports":[],"exports":["a","b","c"],"inputs":{"src/plugins/retry.ts":{"bytesInOutput":346},"src/plugins/cache/server.ts":{"bytesInOutput":199}},"bytes":575},"dist/esm/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/esm/types.js":{"imports":[],"exports":[],"entryPoint":"main/types.ts","inputs":{"main/types.ts":{"bytesInOutput":0}},"bytes":0}}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a as AlyvroAxiosInstance } from './api-BD94m-ym.mjs';
|
|
2
|
+
import { R as ReturnFunction } from './cache-BA2IH48s.mjs';
|
|
3
|
+
import 'axios';
|
|
4
|
+
|
|
5
|
+
declare const serverCachePlugin: ReturnFunction;
|
|
6
|
+
|
|
7
|
+
declare const createAbortController: () => AbortController;
|
|
8
|
+
|
|
9
|
+
declare const retry: (instance: AlyvroAxiosInstance) => void;
|
|
10
|
+
|
|
11
|
+
export { serverCachePlugin as cache, createAbortController, retry };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a as AlyvroAxiosInstance } from './api-BD94m-ym.js';
|
|
2
|
+
import { R as ReturnFunction } from './cache-BA2IH48s.js';
|
|
3
|
+
import 'axios';
|
|
4
|
+
|
|
5
|
+
declare const serverCachePlugin: ReturnFunction;
|
|
6
|
+
|
|
7
|
+
declare const createAbortController: () => AbortController;
|
|
8
|
+
|
|
9
|
+
declare const retry: (instance: AlyvroAxiosInstance) => void;
|
|
10
|
+
|
|
11
|
+
export { serverCachePlugin as cache, createAbortController, retry };
|
package/dist/plugins.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCXFF7RVFjs = require('./chunk-CXFF7RVF.js');var t=()=>new AbortController;exports.cache = _chunkCXFF7RVFjs.c; exports.createAbortController = t; exports.retry = _chunkCXFF7RVFjs.a;
|
|
2
|
+
//# sourceMappingURL=plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\AlyvroService\\api-service\\dist\\plugins.js"],"names":[],"mappings":"AAAA,+HAA8C,IAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,eAAe,CAAC,0GAAwD","file":"D:\\AlyvroService\\api-service\\dist\\plugins.js","sourcesContent":[null]}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { A as ApiTypes, a as ConfigEnvType, d as ConfigMiddlewareErrorsType, c as ConfigMiddlewareHeadersType, e as ConfigMiddlewareType, b as ConfigSettingType, C as ConfigType } from './config-Bc2nkAbT.mjs';
|
|
2
|
+
export { C as CacheEntry, R as ReturnFunction } from './cache-BA2IH48s.mjs';
|
|
3
|
+
import 'axios';
|
|
4
|
+
|
|
5
|
+
type TelegramNetworkObjectType = {
|
|
6
|
+
status_code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
method: string;
|
|
9
|
+
originalUrl: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type { TelegramNetworkObjectType };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { A as ApiTypes, a as ConfigEnvType, d as ConfigMiddlewareErrorsType, c as ConfigMiddlewareHeadersType, e as ConfigMiddlewareType, b as ConfigSettingType, C as ConfigType } from './config-Bc2nkAbT.js';
|
|
2
|
+
export { C as CacheEntry, R as ReturnFunction } from './cache-BA2IH48s.js';
|
|
3
|
+
import 'axios';
|
|
4
|
+
|
|
5
|
+
type TelegramNetworkObjectType = {
|
|
6
|
+
status_code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
method: string;
|
|
9
|
+
originalUrl: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type { TelegramNetworkObjectType };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\AlyvroService\\api-service\\dist\\types.js"],"names":[],"mappings":"AAAA","file":"D:\\AlyvroService\\api-service\\dist\\types.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alyvro/api-service",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "A minimal yet powerful service for sending HTTP requests on the client and handling them gracefully on the server. No complicated setup. Just plug in your keys — and you're ready to go.",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./plugins": {
|
|
19
|
+
"types": "./dist/plugins.d.ts",
|
|
20
|
+
"import": "./dist/esm/plugins.js",
|
|
21
|
+
"require": "./dist/plugins.js"
|
|
22
|
+
},
|
|
23
|
+
"./types": {
|
|
24
|
+
"types": "./dist/types.d.ts",
|
|
25
|
+
"import": "./dist/esm/types.js",
|
|
26
|
+
"require": "./dist/types.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"api-service",
|
|
31
|
+
"api",
|
|
32
|
+
"alyvro-package",
|
|
33
|
+
"alyvro"
|
|
34
|
+
],
|
|
35
|
+
"author": "alyvro",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"url": "git+https://github.com/Alyvro/api-service.git"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/Alyvro/api-service/issues",
|
|
42
|
+
"email": "support@alyvro.com"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"axios": "^1.11.0",
|
|
46
|
+
"express": "^5.1.0",
|
|
47
|
+
"jsonwebtoken": "^9.0.2",
|
|
48
|
+
"parse-url": "^10.0.3",
|
|
49
|
+
"tsup": "^8.5.0",
|
|
50
|
+
"zlib": "^1.0.5"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
54
|
+
"@types/axios": "^0.14.4",
|
|
55
|
+
"@types/express": "^5.0.3",
|
|
56
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
57
|
+
"@types/node": "^24.1.0",
|
|
58
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
59
|
+
"msw": "^2.11.3",
|
|
60
|
+
"release-it": "^19.0.5",
|
|
61
|
+
"tsx": "^4.20.3",
|
|
62
|
+
"typescript": "^5.8.3",
|
|
63
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
64
|
+
"vitest": "^3.2.4",
|
|
65
|
+
"whatwg-fetch": "^3.6.20"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "pnpm remove-dist && tsup",
|
|
69
|
+
"remove-dist": "tsx scripts/remove-dist.ts",
|
|
70
|
+
"rel": "pnpm build && pnpm publish",
|
|
71
|
+
"test": "vitest --run",
|
|
72
|
+
"coverage": "vitest run --coverage",
|
|
73
|
+
"release": "release-it",
|
|
74
|
+
"changelog": "release-it --only-changelog"
|
|
75
|
+
}
|
|
76
|
+
}
|