@ajke/core 0.1.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 +357 -0
- package/dist/chunk-AT2R2CGV.js +234 -0
- package/dist/chunk-AT2R2CGV.js.map +1 -0
- package/dist/chunk-EUXUH3YW.js +15 -0
- package/dist/chunk-EUXUH3YW.js.map +1 -0
- package/dist/chunk-YUBEJL4T.cjs +234 -0
- package/dist/chunk-YUBEJL4T.cjs.map +1 -0
- package/dist/chunk-ZBDE64SD.cjs +15 -0
- package/dist/chunk-ZBDE64SD.cjs.map +1 -0
- package/dist/config.cjs +10 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +13 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +10 -0
- package/dist/config.js.map +1 -0
- package/dist/index.cjs +974 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +255 -0
- package/dist/index.d.ts +255 -0
- package/dist/index.js +974 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/index.cjs +10 -0
- package/dist/middleware/index.cjs.map +1 -0
- package/dist/middleware/index.d.cts +18 -0
- package/dist/middleware/index.d.ts +18 -0
- package/dist/middleware/index.js +10 -0
- package/dist/middleware/index.js.map +1 -0
- package/package.json +56 -0
- package/src/README.md +285 -0
- package/src/config.ts +14 -0
- package/src/context/execution-context.ts +36 -0
- package/src/context/index.ts +1 -0
- package/src/decorators/core/exception-filters.decorator.ts +24 -0
- package/src/decorators/core/index.ts +6 -0
- package/src/decorators/core/injectable.decorator.ts +41 -0
- package/src/decorators/core/optional.decorator.ts +9 -0
- package/src/decorators/core/set-metadata.decorator.ts +20 -0
- package/src/decorators/core/use-guards.decorator.ts +14 -0
- package/src/decorators/core/use-interceptors.decorator.ts +16 -0
- package/src/decorators/http/controller.decorator.ts +230 -0
- package/src/decorators/http/header.decorator.ts +11 -0
- package/src/decorators/http/http-code.decorator.ts +8 -0
- package/src/decorators/http/index.ts +6 -0
- package/src/decorators/http/redirect.decorator.ts +13 -0
- package/src/decorators/http/route-mapping.decorator.ts +22 -0
- package/src/decorators/http/route-params.decorator.ts +60 -0
- package/src/decorators/index.ts +3 -0
- package/src/decorators/modules/global.decorator.ts +8 -0
- package/src/decorators/modules/index.ts +2 -0
- package/src/decorators/modules/module.decorator.ts +16 -0
- package/src/exceptions/http-exception.ts +17 -0
- package/src/exceptions/http-exceptions.ts +85 -0
- package/src/exceptions/index.ts +2 -0
- package/src/index.ts +11 -0
- package/src/injector/index.ts +1 -0
- package/src/injector/injector.ts +103 -0
- package/src/injector/module-compiler.ts +48 -0
- package/src/injector/module.factory.ts +74 -0
- package/src/interfaces/core/filter.interface.ts +5 -0
- package/src/interfaces/core/guard.interface.ts +5 -0
- package/src/interfaces/core/index.ts +5 -0
- package/src/interfaces/core/interceptor.interface.ts +9 -0
- package/src/interfaces/core/lifecycle.interface.ts +19 -0
- package/src/interfaces/core/pipe.interface.ts +9 -0
- package/src/interfaces/http/index.ts +1 -0
- package/src/interfaces/http/response.interface.ts +27 -0
- package/src/interfaces/index.ts +3 -0
- package/src/interfaces/modules/index.ts +1 -0
- package/src/interfaces/modules/module.interface.ts +17 -0
- package/src/middleware/error-handler.middleware.ts +63 -0
- package/src/middleware/index.ts +2 -0
- package/src/middleware/request-logger.middleware.ts +17 -0
- package/src/pipes/index.ts +3 -0
- package/src/pipes/validate.pipe.ts +79 -0
- package/src/pipes/zod-query.pipe.ts +42 -0
- package/src/pipes/zod-validate.pipe.ts +49 -0
- package/src/services/index.ts +1 -0
- package/src/services/reflector.service.ts +24 -0
- package/src/utils/apply-decorators.util.ts +17 -0
- package/src/utils/forward-ref.util.ts +14 -0
- package/src/utils/index.ts +22 -0
- package/src/utils/logger.util.ts +189 -0
- package/src/utils/response.util.ts +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wilt Contributors
|
|
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,357 @@
|
|
|
1
|
+
# @ajke/core
|
|
2
|
+
|
|
3
|
+
A lightweight, NestJS-inspired framework for building modular APIs on Cloudflare Workers using [Hono](https://hono.dev) as the HTTP layer.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ajke/core hono reflect-metadata tsyringe zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Your `tsconfig.json` must have:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"compilerOptions": {
|
|
16
|
+
"experimentalDecorators": true,
|
|
17
|
+
"emitDecoratorMetadata": true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// src/index.ts
|
|
28
|
+
import "reflect-metadata";
|
|
29
|
+
import { createModule } from "@ajke/core";
|
|
30
|
+
import { requestLogger } from "@ajke/core/middleware";
|
|
31
|
+
import { AppModule } from "./app.module";
|
|
32
|
+
|
|
33
|
+
const app = createModule(AppModule, {
|
|
34
|
+
middlewares: [requestLogger],
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
fetch(request: Request, env: CloudflareBindings, ctx: ExecutionContext) {
|
|
39
|
+
return app.fetch(request, env, ctx);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// src/app.module.ts
|
|
46
|
+
import { Module, createModule } from "@ajke/core";
|
|
47
|
+
import { HelloModule } from "./modules/hello/hello.module";
|
|
48
|
+
|
|
49
|
+
@Module({ imports: [HelloModule] })
|
|
50
|
+
export class AppModule {}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// src/modules/hello/hello.module.ts
|
|
55
|
+
import { Module } from "@ajke/core";
|
|
56
|
+
import { HelloController } from "./hello.controller";
|
|
57
|
+
import { HelloService } from "./hello.service";
|
|
58
|
+
|
|
59
|
+
@Module({ controllers: [HelloController], providers: [HelloService] })
|
|
60
|
+
export class HelloModule {}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// src/modules/hello/hello.controller.ts
|
|
65
|
+
import { Controller, Get, Inject } from "@ajke/core";
|
|
66
|
+
import { HelloService } from "./hello.service";
|
|
67
|
+
|
|
68
|
+
@Controller("/hello")
|
|
69
|
+
export class HelloController {
|
|
70
|
+
constructor(@Inject(HelloService) private helloService: HelloService) {}
|
|
71
|
+
|
|
72
|
+
@Get()
|
|
73
|
+
greet() {
|
|
74
|
+
return { message: this.helloService.greet() };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// src/modules/hello/hello.service.ts
|
|
81
|
+
import { Injectable } from "@ajke/core";
|
|
82
|
+
|
|
83
|
+
@Injectable()
|
|
84
|
+
export class HelloService {
|
|
85
|
+
greet() {
|
|
86
|
+
return "Hello from Ajke!";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Core Concepts
|
|
94
|
+
|
|
95
|
+
| Concept | Decorator / API | Purpose |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| Module | `@Module` | Group controllers and providers |
|
|
98
|
+
| Global Module | `@Global` | Make a module's providers available everywhere |
|
|
99
|
+
| Controller | `@Controller` | Handle HTTP routes |
|
|
100
|
+
| Provider | `@Injectable` | Injectable service |
|
|
101
|
+
| Custom injection | `@Inject` | Explicit token injection |
|
|
102
|
+
| Optional dep | `@Optional` | Inject `undefined` if provider not registered |
|
|
103
|
+
| Guards | `@UseGuards` | Authorization — block requests early |
|
|
104
|
+
| Interceptors | `@UseInterceptors` | Transform requests/responses |
|
|
105
|
+
| Exception filters | `@UseFilters` / `@Catch` | Handle specific thrown exceptions |
|
|
106
|
+
| Metadata | `@SetMetadata` + `Reflector` | Attach and read custom metadata |
|
|
107
|
+
| Lifecycle hooks | `OnModuleInit` | Run code after DI wiring |
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## HTTP Decorators
|
|
112
|
+
|
|
113
|
+
### Route mapping
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
@Get(path?) @Post(path?) @Put(path?) @Delete(path?) @Patch(path?)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Parameter decorators
|
|
120
|
+
|
|
121
|
+
Extract values directly as handler arguments — no manual `c.req` parsing needed.
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
@Body(property?) // entire body, or body[property]
|
|
125
|
+
@Param(name?) // route param :name, or all params as object
|
|
126
|
+
@Query(name?) // query string ?name=, or all queries as object
|
|
127
|
+
@Headers(name?) // single header, or all headers as object
|
|
128
|
+
@Ip() // client IP (CF-Connecting-IP / X-Forwarded-For)
|
|
129
|
+
@Req() // full Hono Context — escape hatch
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Response decorators
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
@HttpCode(201) // override default 200/204
|
|
136
|
+
@Header('Cache-Control', 'no-store') // set a response header
|
|
137
|
+
@Redirect('/new-url', 301) // redirect response
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Validation
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { ZodValidate, QueryValidate } from "@ajke/core";
|
|
146
|
+
import { z } from "zod";
|
|
147
|
+
|
|
148
|
+
const CreateUserDto = z.object({ name: z.string(), email: z.string().email() });
|
|
149
|
+
|
|
150
|
+
@Post()
|
|
151
|
+
@ZodValidate(CreateUserDto) // validates body; result in c.get('validatedData')
|
|
152
|
+
async create(@Body() body: unknown) { ... }
|
|
153
|
+
|
|
154
|
+
@Get()
|
|
155
|
+
@QueryValidate(SearchDto) // validates query params; result in c.get('validatedQuery')
|
|
156
|
+
async search() { ... }
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Guards
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import { Injectable, CanActivate, ExecutionContext, UseGuards } from "@ajke/core";
|
|
165
|
+
|
|
166
|
+
@Injectable()
|
|
167
|
+
export class AuthGuard implements CanActivate {
|
|
168
|
+
canActivate(context: ExecutionContext): boolean {
|
|
169
|
+
const c = context.switchToHttp().getRequest();
|
|
170
|
+
return !!c.req.header("authorization");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@Controller("/users")
|
|
175
|
+
@UseGuards(AuthGuard)
|
|
176
|
+
export class UsersController { ... }
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
A guard returning `false` causes Ajke to throw `ForbiddenException` automatically.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Interceptors
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { Injectable, NestInterceptor, ExecutionContext, CallHandler, UseInterceptors } from "@ajke/core";
|
|
187
|
+
|
|
188
|
+
@Injectable()
|
|
189
|
+
export class LoggingInterceptor implements NestInterceptor {
|
|
190
|
+
async intercept(context: ExecutionContext, next: CallHandler) {
|
|
191
|
+
const start = Date.now();
|
|
192
|
+
const result = await next.handle();
|
|
193
|
+
console.log(`Took ${Date.now() - start}ms`);
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
@Get()
|
|
199
|
+
@UseInterceptors(LoggingInterceptor)
|
|
200
|
+
async getAll() { ... }
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Exception Filters
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { Catch, ExceptionFilter, ArgumentsHost, HttpException, UseFilters } from "@ajke/core";
|
|
209
|
+
import type { Context } from "hono";
|
|
210
|
+
|
|
211
|
+
@Catch(HttpException)
|
|
212
|
+
export class HttpExceptionFilter implements ExceptionFilter<HttpException> {
|
|
213
|
+
catch(exception: HttpException, host: ArgumentsHost): Response {
|
|
214
|
+
const c = host.switchToHttp().getRequest<Context>();
|
|
215
|
+
return c.json({ statusCode: exception.getStatus(), message: exception.getResponse() }, exception.getStatus() as any);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@Controller("/users")
|
|
220
|
+
@UseFilters(HttpExceptionFilter)
|
|
221
|
+
export class UsersController { ... }
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Built-in Exceptions
|
|
227
|
+
|
|
228
|
+
Throw these anywhere — the built-in `errorHandler` middleware catches them automatically.
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
throw new BadRequestException("Invalid input");
|
|
232
|
+
throw new UnauthorizedException();
|
|
233
|
+
throw new ForbiddenException("Insufficient permissions");
|
|
234
|
+
throw new NotFoundException("User not found");
|
|
235
|
+
throw new ConflictException("Email already exists");
|
|
236
|
+
throw new UnprocessableEntityException({ message: "Validation failed", errors: [] });
|
|
237
|
+
throw new TooManyRequestsException();
|
|
238
|
+
throw new InternalServerErrorException();
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Extend `HttpException` for custom errors:
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
export class PaymentRequiredException extends HttpException {
|
|
245
|
+
constructor() { super("Payment required", 402); }
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## SetMetadata + Reflector
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
// Define a helper decorator
|
|
255
|
+
export const Roles = (...roles: string[]) => SetMetadata("roles", roles);
|
|
256
|
+
|
|
257
|
+
// Use on a route
|
|
258
|
+
@Roles("admin")
|
|
259
|
+
@Get()
|
|
260
|
+
async adminOnly() { ... }
|
|
261
|
+
|
|
262
|
+
// Read in a guard
|
|
263
|
+
@Injectable()
|
|
264
|
+
export class RolesGuard implements CanActivate {
|
|
265
|
+
constructor(private reflector: Reflector) {}
|
|
266
|
+
|
|
267
|
+
canActivate(context: ExecutionContext): boolean {
|
|
268
|
+
const required = this.reflector.getAllAndOverride<string[]>("roles", [
|
|
269
|
+
context.getHandler(),
|
|
270
|
+
context.getClass(),
|
|
271
|
+
]);
|
|
272
|
+
if (!required) return true;
|
|
273
|
+
// check user roles...
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Lifecycle Hooks
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
import { Injectable, OnModuleInit } from "@ajke/core";
|
|
285
|
+
|
|
286
|
+
@Injectable()
|
|
287
|
+
export class DatabaseService implements OnModuleInit {
|
|
288
|
+
async onModuleInit() {
|
|
289
|
+
await this.connect();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Dependency Injection
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
// Type-based (automatic)
|
|
300
|
+
constructor(private userService: UserService) {}
|
|
301
|
+
|
|
302
|
+
// Explicit token
|
|
303
|
+
constructor(@Inject(UserService) private userService: UserService) {}
|
|
304
|
+
|
|
305
|
+
// Circular references
|
|
306
|
+
constructor(@Inject(forwardRef(() => ServiceB)) private b: ServiceB) {}
|
|
307
|
+
|
|
308
|
+
// Optional
|
|
309
|
+
constructor(@Optional() private cache?: CacheService) {}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Auto-Serialization
|
|
315
|
+
|
|
316
|
+
When parameter decorators (`@Body`, `@Param`, etc.) are used, handlers may return plain values:
|
|
317
|
+
|
|
318
|
+
| Return value | Response |
|
|
319
|
+
|---|---|
|
|
320
|
+
| Plain object / array | `c.json(result, 200)` |
|
|
321
|
+
| `undefined` / `null` | `204 No Content` |
|
|
322
|
+
| `Response` object | Returned as-is |
|
|
323
|
+
|
|
324
|
+
Without parameter decorators, the handler receives the raw Hono `Context` as the first argument (backward-compatible).
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Middleware
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
import { requestLogger, errorHandler } from "@ajke/core/middleware";
|
|
332
|
+
|
|
333
|
+
const app = createModule(AppModule, {
|
|
334
|
+
middlewares: [errorHandler, requestLogger],
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Config (`ajke.config.ts`)
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
import { defineConfig } from "@ajke/core/config";
|
|
344
|
+
|
|
345
|
+
export default defineConfig({
|
|
346
|
+
modulesDir: "src/modules/app",
|
|
347
|
+
generate: {
|
|
348
|
+
files: ["module", "controller", "service", "dto", "entity", "test"],
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## License
|
|
356
|
+
|
|
357
|
+
MIT
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// src/exceptions/http-exception.ts
|
|
2
|
+
var HttpException = class extends Error {
|
|
3
|
+
constructor(response, statusCode) {
|
|
4
|
+
super(typeof response === "string" ? response : response.message ?? "HttpException");
|
|
5
|
+
this.response = response;
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
this.name = "HttpException";
|
|
8
|
+
}
|
|
9
|
+
response;
|
|
10
|
+
statusCode;
|
|
11
|
+
getStatus() {
|
|
12
|
+
return this.statusCode;
|
|
13
|
+
}
|
|
14
|
+
getResponse() {
|
|
15
|
+
return this.response;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/middleware/error-handler.middleware.ts
|
|
20
|
+
function isHttpException(err) {
|
|
21
|
+
return err instanceof HttpException || err instanceof Error && typeof err.getStatus === "function" && typeof err.getResponse === "function";
|
|
22
|
+
}
|
|
23
|
+
function isZodError(err) {
|
|
24
|
+
return err instanceof Error && err.name === "ZodError" && Array.isArray(err.issues);
|
|
25
|
+
}
|
|
26
|
+
async function errorHandler(c, next) {
|
|
27
|
+
try {
|
|
28
|
+
await next();
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (isHttpException(error)) {
|
|
31
|
+
const response = error.getResponse();
|
|
32
|
+
const body = typeof response === "string" ? { success: false, error: { code: error.name, message: response }, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : { success: false, ...response, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
33
|
+
return c.json(body, error.getStatus());
|
|
34
|
+
}
|
|
35
|
+
if (isZodError(error)) {
|
|
36
|
+
const details = error.issues.map((i) => ({
|
|
37
|
+
field: i.path.join("."),
|
|
38
|
+
message: i.message,
|
|
39
|
+
code: i.code
|
|
40
|
+
}));
|
|
41
|
+
return c.json(
|
|
42
|
+
{
|
|
43
|
+
success: false,
|
|
44
|
+
error: { code: "VALIDATION_ERROR", message: "Validation failed", details },
|
|
45
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
46
|
+
},
|
|
47
|
+
400
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
console.error("Unhandled error:", error);
|
|
51
|
+
return c.json(
|
|
52
|
+
{
|
|
53
|
+
success: false,
|
|
54
|
+
error: {
|
|
55
|
+
code: "INTERNAL_ERROR",
|
|
56
|
+
message: error instanceof Error ? error.message : "Internal server error"
|
|
57
|
+
},
|
|
58
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
59
|
+
},
|
|
60
|
+
500
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/utils/logger.util.ts
|
|
66
|
+
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
67
|
+
LogLevel2["ERROR"] = "error";
|
|
68
|
+
LogLevel2["WARN"] = "warn";
|
|
69
|
+
LogLevel2["INFO"] = "info";
|
|
70
|
+
LogLevel2["DEBUG"] = "debug";
|
|
71
|
+
return LogLevel2;
|
|
72
|
+
})(LogLevel || {});
|
|
73
|
+
var META_PLACEHOLDER = "[unserializable-meta]";
|
|
74
|
+
function stringifyLogMeta(meta) {
|
|
75
|
+
try {
|
|
76
|
+
const keys = Object.keys(meta).sort();
|
|
77
|
+
const sorted = {};
|
|
78
|
+
for (const k of keys) sorted[k] = meta[k];
|
|
79
|
+
return JSON.stringify(sorted);
|
|
80
|
+
} catch {
|
|
81
|
+
return META_PLACEHOLDER;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var colors = {
|
|
85
|
+
reset: "\x1B[0m",
|
|
86
|
+
bright: "\x1B[1m",
|
|
87
|
+
red: "\x1B[31m",
|
|
88
|
+
green: "\x1B[32m",
|
|
89
|
+
yellow: "\x1B[33m",
|
|
90
|
+
blue: "\x1B[34m",
|
|
91
|
+
magenta: "\x1B[35m",
|
|
92
|
+
cyan: "\x1B[36m",
|
|
93
|
+
gray: "\x1B[90m"
|
|
94
|
+
};
|
|
95
|
+
function getStatusColor(status) {
|
|
96
|
+
if (status >= 500) return colors.red;
|
|
97
|
+
if (status >= 400) return colors.yellow;
|
|
98
|
+
if (status >= 300) return colors.cyan;
|
|
99
|
+
if (status >= 200) return colors.green;
|
|
100
|
+
return colors.gray;
|
|
101
|
+
}
|
|
102
|
+
function getMethodColor(method) {
|
|
103
|
+
switch (method) {
|
|
104
|
+
case "GET":
|
|
105
|
+
return colors.green;
|
|
106
|
+
case "POST":
|
|
107
|
+
return colors.blue;
|
|
108
|
+
case "PUT":
|
|
109
|
+
return colors.yellow;
|
|
110
|
+
case "DELETE":
|
|
111
|
+
return colors.red;
|
|
112
|
+
case "PATCH":
|
|
113
|
+
return colors.magenta;
|
|
114
|
+
default:
|
|
115
|
+
return colors.gray;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var Logger = class _Logger {
|
|
119
|
+
static instance;
|
|
120
|
+
logLevel;
|
|
121
|
+
enableColors;
|
|
122
|
+
constructor() {
|
|
123
|
+
this.logLevel = "info" /* INFO */;
|
|
124
|
+
this.enableColors = true;
|
|
125
|
+
}
|
|
126
|
+
static getInstance() {
|
|
127
|
+
if (!_Logger.instance) {
|
|
128
|
+
_Logger.instance = new _Logger();
|
|
129
|
+
}
|
|
130
|
+
return _Logger.instance;
|
|
131
|
+
}
|
|
132
|
+
shouldLog(level) {
|
|
133
|
+
const levels = Object.values(LogLevel);
|
|
134
|
+
const currentLevelIndex = levels.indexOf(this.logLevel);
|
|
135
|
+
const messageLevelIndex = levels.indexOf(level);
|
|
136
|
+
return messageLevelIndex <= currentLevelIndex;
|
|
137
|
+
}
|
|
138
|
+
formatMessage(level, message, context, meta) {
|
|
139
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
140
|
+
const contextStr = context ? ` [${context}]` : "";
|
|
141
|
+
const metaStr = meta && Object.keys(meta).length > 0 ? ` | ${stringifyLogMeta(meta)}` : "";
|
|
142
|
+
const baseMessage = `[${timestamp}] ${level.toUpperCase()}${contextStr}: ${message}${metaStr}`;
|
|
143
|
+
if (!this.enableColors) return baseMessage;
|
|
144
|
+
const colorMap = {
|
|
145
|
+
["error" /* ERROR */]: colors.red,
|
|
146
|
+
["warn" /* WARN */]: colors.yellow,
|
|
147
|
+
["info" /* INFO */]: colors.blue,
|
|
148
|
+
["debug" /* DEBUG */]: colors.gray
|
|
149
|
+
};
|
|
150
|
+
return `${colorMap[level]}${baseMessage}${colors.reset}`;
|
|
151
|
+
}
|
|
152
|
+
// HTTP request logging (like Hono's logger)
|
|
153
|
+
http(method, path, status, duration, userAgent) {
|
|
154
|
+
if (!this.shouldLog("info" /* INFO */)) return;
|
|
155
|
+
const methodColor = this.enableColors ? getMethodColor(method) : "";
|
|
156
|
+
const statusColor = this.enableColors ? getStatusColor(status) : "";
|
|
157
|
+
const reset = this.enableColors ? colors.reset : "";
|
|
158
|
+
const methodStr = `${methodColor}${method}${reset}`;
|
|
159
|
+
const statusStr = `${statusColor}${status}${reset}`;
|
|
160
|
+
const durationStr = duration > 1e3 ? `${colors.red}${duration}ms${reset}` : `${duration}ms`;
|
|
161
|
+
const logMessage = `${methodStr} ${path} ${statusStr} ${durationStr}`;
|
|
162
|
+
if (userAgent) {
|
|
163
|
+
console.log(`${logMessage} - ${colors.gray}${userAgent}${reset}`);
|
|
164
|
+
} else {
|
|
165
|
+
console.log(logMessage);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Standard logging methods
|
|
169
|
+
error(message, context, meta) {
|
|
170
|
+
if (this.shouldLog("error" /* ERROR */)) {
|
|
171
|
+
console.error(this.formatMessage("error" /* ERROR */, message, context, meta));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
warn(message, context, meta) {
|
|
175
|
+
if (this.shouldLog("warn" /* WARN */)) {
|
|
176
|
+
console.warn(this.formatMessage("warn" /* WARN */, message, context, meta));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
info(message, context, meta) {
|
|
180
|
+
if (this.shouldLog("info" /* INFO */)) {
|
|
181
|
+
console.info(this.formatMessage("info" /* INFO */, message, context, meta));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
debug(message, context, meta) {
|
|
185
|
+
if (this.shouldLog("debug" /* DEBUG */)) {
|
|
186
|
+
console.debug(this.formatMessage("debug" /* DEBUG */, message, context, meta));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// Static methods for convenience
|
|
190
|
+
static http(method, path, status, duration, userAgent) {
|
|
191
|
+
_Logger.getInstance().http(method, path, status, duration, userAgent);
|
|
192
|
+
}
|
|
193
|
+
static error(message, context, meta) {
|
|
194
|
+
_Logger.getInstance().error(message, context, meta);
|
|
195
|
+
}
|
|
196
|
+
static warn(message, context, meta) {
|
|
197
|
+
_Logger.getInstance().warn(message, context, meta);
|
|
198
|
+
}
|
|
199
|
+
static info(message, context, meta) {
|
|
200
|
+
_Logger.getInstance().info(message, context, meta);
|
|
201
|
+
}
|
|
202
|
+
static debug(message, context, meta) {
|
|
203
|
+
_Logger.getInstance().debug(message, context, meta);
|
|
204
|
+
}
|
|
205
|
+
// Configuration methods
|
|
206
|
+
setLogLevel(level) {
|
|
207
|
+
this.logLevel = level;
|
|
208
|
+
}
|
|
209
|
+
setColors(enabled) {
|
|
210
|
+
this.enableColors = enabled;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
var logger = Logger.getInstance();
|
|
214
|
+
|
|
215
|
+
// src/middleware/request-logger.middleware.ts
|
|
216
|
+
async function requestLogger(c, next) {
|
|
217
|
+
const start = Date.now();
|
|
218
|
+
const method = c.req.method;
|
|
219
|
+
const path = c.req.path;
|
|
220
|
+
const userAgent = c.req.header("User-Agent");
|
|
221
|
+
await next();
|
|
222
|
+
const end = Date.now();
|
|
223
|
+
const duration = end - start;
|
|
224
|
+
const status = c.res.status;
|
|
225
|
+
logger.http(method, path, status, duration, userAgent);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
HttpException,
|
|
230
|
+
logger,
|
|
231
|
+
errorHandler,
|
|
232
|
+
requestLogger
|
|
233
|
+
};
|
|
234
|
+
//# sourceMappingURL=chunk-AT2R2CGV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/exceptions/http-exception.ts","../src/middleware/error-handler.middleware.ts","../src/utils/logger.util.ts","../src/middleware/request-logger.middleware.ts"],"sourcesContent":["export class HttpException extends Error {\n\tconstructor(\n\t\tprivate readonly response: string | Record<string, any>,\n\t\tprivate readonly statusCode: number\n\t) {\n\t\tsuper(typeof response === \"string\" ? response : (response as any).message ?? \"HttpException\");\n\t\tthis.name = \"HttpException\";\n\t}\n\n\tgetStatus(): number {\n\t\treturn this.statusCode;\n\t}\n\n\tgetResponse(): string | Record<string, any> {\n\t\treturn this.response;\n\t}\n}\n","import type { Context, Next } from \"hono\";\nimport { HttpException } from \"../exceptions/http-exception\";\n\nfunction isHttpException(err: unknown): err is HttpException {\n\treturn (\n\t\terr instanceof HttpException ||\n\t\t(err instanceof Error &&\n\t\t\ttypeof (err as any).getStatus === \"function\" &&\n\t\t\ttypeof (err as any).getResponse === \"function\")\n\t);\n}\n\nfunction isZodError(err: unknown): err is Error & { issues: Array<{ path: (string | number)[]; message: string; code: string }> } {\n\treturn (\n\t\terr instanceof Error &&\n\t\t(err as any).name === \"ZodError\" &&\n\t\tArray.isArray((err as any).issues)\n\t);\n}\n\nexport async function errorHandler(c: Context, next: Next) {\n\ttry {\n\t\tawait next();\n\t} catch (error) {\n\t\tif (isHttpException(error)) {\n\t\t\tconst response = error.getResponse();\n\t\t\tconst body =\n\t\t\t\ttypeof response === \"string\"\n\t\t\t\t\t? { success: false, error: { code: error.name, message: response }, timestamp: new Date().toISOString() }\n\t\t\t\t\t: { success: false, ...response, timestamp: new Date().toISOString() };\n\t\t\treturn c.json(body, error.getStatus() as any);\n\t\t}\n\n\t\tif (isZodError(error)) {\n\t\t\tconst details = error.issues.map((i) => ({\n\t\t\t\tfield: i.path.join(\".\"),\n\t\t\t\tmessage: i.message,\n\t\t\t\tcode: i.code,\n\t\t\t}));\n\t\t\treturn c.json(\n\t\t\t\t{\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: { code: \"VALIDATION_ERROR\", message: \"Validation failed\", details },\n\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t},\n\t\t\t\t400,\n\t\t\t);\n\t\t}\n\n\t\tconsole.error(\"Unhandled error:\", error);\n\t\treturn c.json(\n\t\t\t{\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: \"INTERNAL_ERROR\",\n\t\t\t\t\tmessage: error instanceof Error ? error.message : \"Internal server error\",\n\t\t\t\t},\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t},\n\t\t\t500\n\t\t);\n\t}\n}\n","export enum LogLevel {\n\tERROR = \"error\",\n\tWARN = \"warn\",\n\tINFO = \"info\",\n\tDEBUG = \"debug\",\n}\n\nconst META_PLACEHOLDER = \"[unserializable-meta]\";\n\n/** Stable, one-line JSON for log drains / grepping (keys sorted). */\nexport function stringifyLogMeta(meta: Record<string, unknown>): string {\n\ttry {\n\t\tconst keys = Object.keys(meta).sort();\n\t\tconst sorted: Record<string, unknown> = {};\n\t\tfor (const k of keys) sorted[k] = meta[k];\n\t\treturn JSON.stringify(sorted);\n\t} catch {\n\t\treturn META_PLACEHOLDER;\n\t}\n}\n\nexport function formatError(error: unknown): string {\n\tif (error instanceof Error) {\n\t\tconst stack = error.stack ? error.stack.split(\"\\n\").slice(0, 4).join(\" | \") : \"\";\n\t\treturn stack ? `${error.message} | ${stack}` : error.message;\n\t}\n\treturn String(error);\n}\n\n// ANSI color codes for terminal output\nconst colors = {\n\treset: \"\\x1b[0m\",\n\tbright: \"\\x1b[1m\",\n\tred: \"\\x1b[31m\",\n\tgreen: \"\\x1b[32m\",\n\tyellow: \"\\x1b[33m\",\n\tblue: \"\\x1b[34m\",\n\tmagenta: \"\\x1b[35m\",\n\tcyan: \"\\x1b[36m\",\n\tgray: \"\\x1b[90m\",\n};\n\n// HTTP status code colors\nfunction getStatusColor(status: number): string {\n\tif (status >= 500) return colors.red;\n\tif (status >= 400) return colors.yellow;\n\tif (status >= 300) return colors.cyan;\n\tif (status >= 200) return colors.green;\n\treturn colors.gray;\n}\n\n// HTTP method colors\nfunction getMethodColor(method: string): string {\n\tswitch (method) {\n\t\tcase \"GET\":\n\t\t\treturn colors.green;\n\t\tcase \"POST\":\n\t\t\treturn colors.blue;\n\t\tcase \"PUT\":\n\t\t\treturn colors.yellow;\n\t\tcase \"DELETE\":\n\t\t\treturn colors.red;\n\t\tcase \"PATCH\":\n\t\t\treturn colors.magenta;\n\t\tdefault:\n\t\t\treturn colors.gray;\n\t}\n}\n\nexport class Logger {\n\tprivate static instance: Logger;\n\tprivate logLevel: LogLevel;\n\tprivate enableColors: boolean;\n\n\tprivate constructor() {\n\t\tthis.logLevel = LogLevel.INFO;\n\t\tthis.enableColors = true; // Enable colors by default\n\t}\n\n\tpublic static getInstance(): Logger {\n\t\tif (!Logger.instance) {\n\t\t\tLogger.instance = new Logger();\n\t\t}\n\t\treturn Logger.instance;\n\t}\n\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\tconst levels = Object.values(LogLevel);\n\t\tconst currentLevelIndex = levels.indexOf(this.logLevel);\n\t\tconst messageLevelIndex = levels.indexOf(level);\n\t\treturn messageLevelIndex <= currentLevelIndex;\n\t}\n\n\tprivate formatMessage(level: LogLevel, message: string, context?: string, meta?: Record<string, unknown>): string {\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst contextStr = context ? ` [${context}]` : \"\";\n\t\tconst metaStr = meta && Object.keys(meta).length > 0 ? ` | ${stringifyLogMeta(meta)}` : \"\";\n\t\tconst baseMessage = `[${timestamp}] ${level.toUpperCase()}${contextStr}: ${message}${metaStr}`;\n\n\t\tif (!this.enableColors) return baseMessage;\n\n\t\tconst colorMap = {\n\t\t\t[LogLevel.ERROR]: colors.red,\n\t\t\t[LogLevel.WARN]: colors.yellow,\n\t\t\t[LogLevel.INFO]: colors.blue,\n\t\t\t[LogLevel.DEBUG]: colors.gray,\n\t\t};\n\n\t\treturn `${colorMap[level]}${baseMessage}${colors.reset}`;\n\t}\n\n\t// HTTP request logging (like Hono's logger)\n\thttp(method: string, path: string, status: number, duration: number, userAgent?: string): void {\n\t\tif (!this.shouldLog(LogLevel.INFO)) return;\n\n\t\tconst methodColor = this.enableColors ? getMethodColor(method) : \"\";\n\t\tconst statusColor = this.enableColors ? getStatusColor(status) : \"\";\n\t\tconst reset = this.enableColors ? colors.reset : \"\";\n\n\t\tconst methodStr = `${methodColor}${method}${reset}`;\n\t\tconst statusStr = `${statusColor}${status}${reset}`;\n\t\tconst durationStr = duration > 1000 ? `${colors.red}${duration}ms${reset}` : `${duration}ms`;\n\n\t\tconst logMessage = `${methodStr} ${path} ${statusStr} ${durationStr}`;\n\n\t\tif (userAgent) {\n\t\t\tconsole.log(`${logMessage} - ${colors.gray}${userAgent}${reset}`);\n\t\t} else {\n\t\t\tconsole.log(logMessage);\n\t\t}\n\t}\n\n\t// Standard logging methods\n\terror(message: string, context?: string, meta?: Record<string, unknown>): void {\n\t\tif (this.shouldLog(LogLevel.ERROR)) {\n\t\t\tconsole.error(this.formatMessage(LogLevel.ERROR, message, context, meta));\n\t\t}\n\t}\n\n\twarn(message: string, context?: string, meta?: Record<string, unknown>): void {\n\t\tif (this.shouldLog(LogLevel.WARN)) {\n\t\t\tconsole.warn(this.formatMessage(LogLevel.WARN, message, context, meta));\n\t\t}\n\t}\n\n\tinfo(message: string, context?: string, meta?: Record<string, unknown>): void {\n\t\tif (this.shouldLog(LogLevel.INFO)) {\n\t\t\tconsole.info(this.formatMessage(LogLevel.INFO, message, context, meta));\n\t\t}\n\t}\n\n\tdebug(message: string, context?: string, meta?: Record<string, unknown>): void {\n\t\tif (this.shouldLog(LogLevel.DEBUG)) {\n\t\t\tconsole.debug(this.formatMessage(LogLevel.DEBUG, message, context, meta));\n\t\t}\n\t}\n\n\t// Static methods for convenience\n\tstatic http(method: string, path: string, status: number, duration: number, userAgent?: string): void {\n\t\tLogger.getInstance().http(method, path, status, duration, userAgent);\n\t}\n\n\tstatic error(message: string, context?: string, meta?: Record<string, unknown>): void {\n\t\tLogger.getInstance().error(message, context, meta);\n\t}\n\n\tstatic warn(message: string, context?: string, meta?: Record<string, unknown>): void {\n\t\tLogger.getInstance().warn(message, context, meta);\n\t}\n\n\tstatic info(message: string, context?: string, meta?: Record<string, unknown>): void {\n\t\tLogger.getInstance().info(message, context, meta);\n\t}\n\n\tstatic debug(message: string, context?: string, meta?: Record<string, unknown>): void {\n\t\tLogger.getInstance().debug(message, context, meta);\n\t}\n\n\t// Configuration methods\n\tsetLogLevel(level: LogLevel): void {\n\t\tthis.logLevel = level;\n\t}\n\n\tsetColors(enabled: boolean): void {\n\t\tthis.enableColors = enabled;\n\t}\n}\n\nexport const logger = Logger.getInstance();\n","import type { Context, Next } from \"hono\";\nimport { logger } from \"../utils/logger.util\";\n\nexport async function requestLogger(c: Context, next: Next) {\n\tconst start = Date.now();\n\tconst method = c.req.method;\n\tconst path = c.req.path;\n\tconst userAgent = c.req.header(\"User-Agent\");\n\n\tawait next();\n\n\tconst end = Date.now();\n\tconst duration = end - start;\n\tconst status = c.res.status;\n\n\tlogger.http(method, path, status, duration, userAgent);\n}\n"],"mappings":";AAAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACxC,YACkB,UACA,YAChB;AACD,UAAM,OAAO,aAAa,WAAW,WAAY,SAAiB,WAAW,eAAe;AAH3E;AACA;AAGjB,SAAK,OAAO;AAAA,EACb;AAAA,EALkB;AAAA,EACA;AAAA,EAMlB,YAAoB;AACnB,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,cAA4C;AAC3C,WAAO,KAAK;AAAA,EACb;AACD;;;ACbA,SAAS,gBAAgB,KAAoC;AAC5D,SACC,eAAe,iBACd,eAAe,SACf,OAAQ,IAAY,cAAc,cAClC,OAAQ,IAAY,gBAAgB;AAEvC;AAEA,SAAS,WAAW,KAA8G;AACjI,SACC,eAAe,SACd,IAAY,SAAS,cACtB,MAAM,QAAS,IAAY,MAAM;AAEnC;AAEA,eAAsB,aAAa,GAAY,MAAY;AAC1D,MAAI;AACH,UAAM,KAAK;AAAA,EACZ,SAAS,OAAO;AACf,QAAI,gBAAgB,KAAK,GAAG;AAC3B,YAAM,WAAW,MAAM,YAAY;AACnC,YAAM,OACL,OAAO,aAAa,WACjB,EAAE,SAAS,OAAO,OAAO,EAAE,MAAM,MAAM,MAAM,SAAS,SAAS,GAAG,YAAW,oBAAI,KAAK,GAAE,YAAY,EAAE,IACtG,EAAE,SAAS,OAAO,GAAG,UAAU,YAAW,oBAAI,KAAK,GAAE,YAAY,EAAE;AACvE,aAAO,EAAE,KAAK,MAAM,MAAM,UAAU,CAAQ;AAAA,IAC7C;AAEA,QAAI,WAAW,KAAK,GAAG;AACtB,YAAM,UAAU,MAAM,OAAO,IAAI,CAAC,OAAO;AAAA,QACxC,OAAO,EAAE,KAAK,KAAK,GAAG;AAAA,QACtB,SAAS,EAAE;AAAA,QACX,MAAM,EAAE;AAAA,MACT,EAAE;AACF,aAAO,EAAE;AAAA,QACR;AAAA,UAC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","names":["LogLevel"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
__decorateClass
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-EUXUH3YW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|