@heliosjs/core 1.0.5 → 1.0.7

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.
Files changed (53) hide show
  1. package/README.md +15 -529
  2. package/dist/decorators.d.ts +3 -3
  3. package/dist/decorators.js +1 -1
  4. package/dist/decorators.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/types/core/common.d.ts +7 -7
  7. package/dist/types/core/error.d.ts +27 -10
  8. package/dist/types/core/request.d.ts +11 -11
  9. package/dist/types/core/response.d.ts +18 -3
  10. package/dist/types/core/sse.d.ts +3 -3
  11. package/dist/types/ws/index.d.ts +7 -7
  12. package/dist/utils/core/controller.d.ts +4 -4
  13. package/dist/utils/core/controller.js +12 -13
  14. package/dist/utils/core/controller.js.map +1 -1
  15. package/dist/utils/core/cors.d.ts +3 -5
  16. package/dist/utils/core/cors.js +5 -69
  17. package/dist/utils/core/cors.js.map +1 -1
  18. package/dist/utils/core/error/apperror.d.ts +2 -2
  19. package/dist/utils/core/error/apperror.js +1 -1
  20. package/dist/utils/core/error/apperror.js.map +1 -1
  21. package/dist/utils/core/error/base.d.ts +7 -3
  22. package/dist/utils/core/error/base.js +8 -4
  23. package/dist/utils/core/error/base.js.map +1 -1
  24. package/dist/utils/core/error/helpers.d.ts +1 -1
  25. package/dist/utils/core/error/helpers.js +1 -1
  26. package/dist/utils/core/error/helpers.js.map +1 -1
  27. package/dist/utils/core/multipart.d.ts +3 -3
  28. package/dist/utils/core/multipart.js +2 -1
  29. package/dist/utils/core/multipart.js.map +1 -1
  30. package/dist/utils/core/request.d.ts +5 -5
  31. package/dist/utils/core/request.js +2 -2
  32. package/dist/utils/core/request.js.map +1 -1
  33. package/dist/utils/core/response.d.ts +32 -10
  34. package/dist/utils/core/response.js +7 -7
  35. package/dist/utils/core/response.js.map +1 -1
  36. package/dist/utils/core/routeWalker.d.ts +1 -1
  37. package/dist/utils/core/routeWalker.js +8 -8
  38. package/dist/utils/core/routeWalker.js.map +1 -1
  39. package/dist/utils/core/sanitize.d.ts +1 -1
  40. package/dist/utils/core/sanitize.js +1 -1
  41. package/dist/utils/core/sanitize.js.map +1 -1
  42. package/dist/utils/shared/parsers.js +2 -2
  43. package/dist/utils/shared/parsers.js.map +1 -1
  44. package/dist/utils/shared/validate.d.ts +1 -1
  45. package/dist/utils/shared/validate.js +1 -0
  46. package/dist/utils/shared/validate.js.map +1 -1
  47. package/dist/utils/socket/server.d.ts +3 -3
  48. package/dist/utils/socket/server.js +2 -2
  49. package/dist/utils/socket/server.js.map +1 -1
  50. package/dist/utils/socket/service.d.ts +3 -3
  51. package/dist/utils/socket/service.js.map +1 -1
  52. package/dist/utils/socket/socket.js.map +1 -1
  53. package/package.json +4 -1
package/README.md CHANGED
@@ -1,540 +1,26 @@
1
- # Project Overview
2
-
3
- This project is a decorator-based API framework supporting both HTTP and WebSocket servers. It is designed to simplify the creation of scalable and maintainable APIs with features such as controllers, middlewares, interceptors, error handling, and WebSocket support. Additionally, it supports AWS Lambda integration for serverless deployments.
4
-
5
- # Installation
6
-
7
- To install dependencies and build the project, run:
8
-
9
- ```bash
10
- yarn install
11
- # or npm install
12
- ```
13
-
14
- # Usage
15
-
16
- You can use controllers and server functionality by importing controllers and creating server instances as shown in the examples above. Use your preferred testing framework to write unit and integration tests.
17
-
18
- # Project Structure
19
-
20
- - `quantum-flow/http` - Main application source code for HTTP servers.
21
- - `quantum-flow/aws` - Main application source code for AWS Lambda.
22
- - `quantum-flow/core` - Core framework components like Controller and Endpoint.
23
- - `quantum-flow/middlewares` - Core middlewares to use within the application.
24
- - `quantum-flow/ws` - Websocket decorators.
25
- - `quantum-flow/sse` - Server side events decorators.
26
- - `quantum-flow/plugins/aws` - Exports plugins types for lambda.
27
- - `quantum-flow/plugins/http` - Exports plugins types for http server.
28
-
29
1
  ---
30
2
 
31
- ## Defining Controllers
32
-
33
- Use the `@Controller` decorator to define controllers with options such as prefix, sub-controllers, middlewares, and interceptors.
34
-
35
- ```typescript
36
- import {
37
- Body,
38
- Controller,
39
- Headers,
40
- IWebSocketService,
41
- Params,
42
- PUT,
43
- Query,
44
- Request,
45
- Response,
46
- Status,
47
- ANY,
48
- Request,
49
- Response
50
- } from 'quantum-flow/core';
51
- import {IsString} from 'class-validator'
52
- import { Catch, Cors, Sanitize, Use, SANITIZER } from 'quantum-flow/middlewares';
53
- import { InjectWS } from 'quantum-flow/ws';
54
- import { HttpRequest } from 'quantum-flow/http';
55
- // SANITIZER - prefilled Joi schema for common data
56
- class UserDto {
57
- constructor() {}
58
- @IsString()
59
- name: string;
60
- }
61
-
62
- @Controller({
63
- prefix: 'user',
64
- controllers: [UserMetadata, ...],
65
- interceptor: (data, req, res) => data,
66
- })
67
- @Cors({ origin: '*' })
68
- @Catch((err) => ({ status: 500, err }))
69
- @Use(()=>{})
70
- @Sanitize({
71
- schema: Joi.object({name: Joi.string().trim().min(2).max(50).required()}),
72
- action: 'both',
73
- options: { abortEarly: false },
74
- stripUnknown: true,
75
- type: 'body',
76
- })
77
- export class User {
78
- @Status(201)
79
- @PUT(':id',[(req, res)=>{} , ...middlewares])
80
- @Cors({ origin: '*' })
81
- async createUser(
82
- @Body(UserDto) body: UserDto,
83
- @Query() query: Record<string, string | string[]>,
84
- @Headers() headers: Record<string, string | string[]>,
85
- @Params(ParamDTO, 'param') params: string,
86
- @Req() req: Response,
87
- @Response() resp: Request,
88
- @InjectWS() ws: IWebSocketService,
89
- ) {}
90
-
91
- @ANY([...middlewares])
92
- async any(@Response() resp: any) {...}
93
- }
94
-
95
- @Controller(api, [...middlewares])
96
- @Controller({
97
- prefix: 'api',
98
- controllers: [UserController, SocketController],
99
- middlewares: [...middlewares],
100
- interceptor: (data, req, res) => data,
101
- })
102
- @Catch((error) => ({ status: 400, error }))
103
- class RootController {}
104
- ```
105
-
106
- ## Creating a http Server
107
-
108
- Use the `@Server` decorator with configuration options like port, host, controllers, and WebSocket enablement.
109
-
110
- ```typescript
111
- import { Server, Port, Host, Use, Catch, HttpServer } from 'quantum-flow/http';
112
-
113
- @Server({ controllers: [RootController], cors: { origin: '*' } })
114
- @Port(3000)
115
- @Host('localhost')
116
- @Use((data) => data)
117
- @Catch((error) => ({ status: 400, error }))
118
- class App {}
119
-
120
- const server = new HttpServer(App);
121
-
122
- server.listen().catch(console.error);
123
- ```
124
-
125
- ## Middlewares, Interceptors, and Error Handlers
126
-
127
- - Use `@Use` to apply middlewares.
128
- - Use `@Catch` to handle errors.
129
- - Use `@Port` and `@Host` to configure server port and host.
130
- - Use `@Cors` to configure cors.
131
- - Use `@Sanitize` to apply sanitization to reqest.
132
-
133
- ## Request decorators
134
-
135
- - Use `@Body` to handle request bodies.
136
- - Use `@Headers` to access request headers.
137
- - Use `@Query` to handle query parameters.
138
- - Use `@Params` to access route parameters.
139
- - Use `@Files` to access files sent within multipart/form-data requests.
140
- Text sent as multipart/form-data is exposed with `@Body` decorators
141
- - Use `@Req` to access the original request object.
142
- - Use `@Response` to access the original object.
143
- - Use `@InjectWS` to access the websocket service.
144
- - Use `@InjectSSE` to access the server-side-event service.
145
-
146
- # AWS Lambda Support
147
-
148
- Use `LambdaAdapter` to convert API Gateway events to requests and responses. Create Lambda handlers from controllers.
149
-
150
- ```typescript
151
- Example Lambda handler creation
152
- import { LambdaAdapter, LambdaRequest, LambdaResponse } from 'quantum-flow/aws';
153
- import { Request, Query, Headers, Params, Response, Response, Request } from 'quantum-flow/core'
154
-
155
- @Controller({ prefix: 'user' })
156
- class UserController {
157
- @Body(UserDto) body: UserDto,
158
- @Query() query: Record<string, string | string[]>,
159
- @Headers() headers: Record<string, string | string[]>,
160
- @Params(ParamDTO, 'param') params: string,
161
- @Req() req: Request,
162
- @Response() res: Response
163
- ) { }
164
- }
165
- const lambdaAdapter = new LambdaAdapter(UserController);
166
- export const handler = lambdaAdapter.handler;
167
- ```
168
-
169
- You can access context and event throught @Req() decorator:
170
- @Req() request: LambdaRequest
171
- request.context
172
- request.event
173
-
174
- # WebSocket Support
175
-
176
- Enable WebSocket in the server configuration and register WebSocket controllers.
177
-
178
- ## Enabling WebSocket Support in Server
179
-
180
- To enable WS support, configure your HTTP server with the `path: string` option and register controllers that use SSE.
181
-
182
- Example server setup:
183
-
184
- ```typescript
185
- @Server( { websocket: { path:'/ws' } })
186
- ```
187
-
188
- ## Injecting WebSocket events in Controller
189
-
190
- ```typescript
191
- import { OnConnection, Subscribe, OnMessage } from 'quantum-flow/ws';
192
- @Controller('socket')
193
- export class Socket {
194
- @OnConnection()
195
- onConnection(event: WebSocketEvent) {
196
- // Send greeting ONLY to this client
197
- event.client.socket.send(JSON.stringify({ type: 'welcome', data: { message: 'Welcome!' } }));
198
- }
199
-
200
- /**
201
- * 2. @Subscribe - AUTOMATIC broadcast to all subscribers
202
- * No need to use WebSocketService!
203
- */
204
- @Subscribe('chat')
205
- onChatMessage(event: WebSocketEvent) {
206
- // This method is called for EACH subscriber
207
- // The message is ALREADY automatically broadcast to all!
208
-
209
- const msg = event.message?.data;
210
- // You can add logic, but no need to broadcast
211
- if (msg?.text.includes('bad')) {
212
- // If return empty, the message will not be sent
213
- return;
214
- }
215
-
216
- // That's it, the message will be sent to subscribers automatically!
217
- }
218
-
219
- /**
220
- * 4. @OnMessage for commands (without WebSocketService)
221
- */
222
- @OnMessage('ping')
223
- onPing(event: WebSocketEvent) {
224
- // Send response only to this client
225
- event.client.socket.send(
226
- JSON.stringify({
227
- type: 'pong',
228
- data: { time: Date.now() },
229
- }),
230
- );
231
- }
232
-
233
- /**
234
- * 5. @OnMessage for subscription
235
- */
236
- @OnMessage('subscribe')
237
- onSubscribe(event: WebSocketEvent) {
238
- const topic = event.message?.data.topic;
239
-
240
- // Server will save the subscription automatically, no need to do anything!
241
- // Just confirm
242
- event.client.socket.send(
243
- JSON.stringify({
244
- type: 'subscribed',
245
- topic,
246
- data: { success: true },
247
- }),
248
- );
249
- }
250
- }
251
- ```
252
-
253
- # Server-Sent Events (SSE) Support
254
-
255
- The framework supports Server-Sent Events (SSE) to enable real-time, one-way communication from the server to clients over HTTP.
256
-
257
- ## Defining SSE Controllers
258
-
259
- Use the `@Controller` decorator to define controllers with a `prefix` and optionally include sub-controllers. This allows modular organization of your API endpoints.
260
-
261
- Example:
262
-
263
- ```typescript
264
- @Controller({
265
- prefix: 'user',
266
- controllers: [UserMetadata],
267
- middlewares: [function UserGlobalUse() {}],
268
- interceptor: (data, req, res) => {
269
- return { data, intercepted: true };
270
- },
271
- })
272
- export class User {}
273
- ```
274
-
275
- ## Injecting SSE Service
276
-
277
- Use the `@InjectSSE` decorator in your controller methods to create and manage SSE connections. This service allows sending events to connected clients.
278
-
279
- Example method using SSE:
280
-
281
- ```typescript
282
- import { InjectSSE } from 'quantum-flow/sse';
283
-
284
- @Controller('user')
285
- export class UserMetadata {
286
- @Get('/subscribesse')
287
- async subscribesse(@InjectSSE() sse) {
288
- const client = sse.createConnection(res);
289
- sse.sendToClient(client.id, {
290
- event: 'welcome message',
291
- data: { message: 'Connected to notifications' },
292
- });
293
- }
294
- }
295
- ```
296
-
297
- ## SSE Event Decorators
298
-
299
- The framework provides decorators to handle SSE connection lifecycle events:
3
+ ````markdown
4
+ # HeliosJS
300
5
 
301
- - `@OnSSEConnection()`: Decorate a method to handle new SSE connections.
302
- - `@OnSSEError()`: Decorate a method to handle SSE errors.
303
- - `@OnSSEClose()`: Decorate a method to handle SSE connection closures.
6
+ 🎯 A modern decorator-based Node.js framework for building scalable applications.
304
7
 
305
- Example usage:
8
+ ## Documentation
306
9
 
307
- ```typescript
308
- import { OnSSEConnection, OnSSEError, OnSSEClose } from 'quantum-flow/sse';
10
+ 👉 **[Full Documentation](https://naumovoleg.github.io/helios/)**
309
11
 
310
- @Controller('user')
311
- export class User {
312
- @OnSSEConnection()
313
- async onsseconnection(@Req() req, @Response() res) {
314
- console.log('SSE connection established');
315
- return req.body;
316
- }
12
+ ## Packages
317
13
 
318
- @OnSSEError()
319
- async onsseerror(@Req() req, @Response() res) {
320
- console.log('SSE error occurred');
321
- return req.body;
322
- }
323
-
324
- @OnSSEClose()
325
- async onsseclose(@Req() req, @Response() res) {
326
- console.log('SSE connection closed');
327
- return req.body;
328
- }
329
- }
330
- ```
331
-
332
- ## Sending SSE Events
333
-
334
- Use the injected SSE service to send events to clients. You can send events to all clients or specific clients by ID.
335
-
336
- Example:
337
-
338
- ```typescript
339
- sse.sendToClient(clientId, { event: 'eventName', data: { key: 'value' } });
340
- ```
341
-
342
- ## Enabling SSE Support in Server
343
-
344
- To enable SSE support, configure your HTTP server with the `sse: true` option and register controllers that use SSE.
345
-
346
- Example server setup:
347
-
348
- ```typescript
349
- import { Server, HttpServer } from 'quantum-flow/http';
350
- import { User, UserMetadata } from './controllers';
351
-
352
- @Server({
353
- controllers: [User, UserMetadata],
354
- sse: { enabled: true },
355
- })
356
- class App {}
357
-
358
- const server = new HttpServer(App);
359
- server.listen().catch(console.error);
360
- ```
361
-
362
- ## Enabling static files
363
-
364
- To enable serving static files, use statics option.
365
-
366
- Example server setup:
367
-
368
- ```typescript
369
- import { Server, HttpServer } from 'quantum-flow/http';
370
- import { User, UserMetadata } from './controllers';
371
-
372
- @Server({
373
- statics: [
374
- {
375
- path: path.join(__dirname, './public'),
376
- options: {
377
- index: 'index.html',
378
- extensions: ['html', 'htm', 'css', 'js'],
379
- maxAge: 86400,
380
- immutable: true,
381
- dotfiles: 'deny',
382
- fallthrough: false,
383
- setHeaders: (res, filePath, stats) => {
384
- if (filePath.endsWith('.css')) {
385
- res.setHeader('Content-Type', 'text/css');
386
- }
387
- },
388
- },
389
- },
390
- ],
391
- })
392
- class App {}
393
-
394
- const server = new HttpServer(App);
395
- server.listen().catch(console.error);
396
- ```
14
+ | Package | Version | Description |
15
+ | ------------------------------------------------------------------------------------------------ | ----------------------- | ---------------------- |
16
+ | [@heliosjs/core](https://github.com/NaumovOleg/heliosjs/tree/master/packages/core) | | Core decorators and DI |
17
+ | [@heliosjs/http](https://github.com/NaumovOleg/heliosjs/tree/master/packages/http) | HTTP server and routing |
18
+ | [@heliosjs/middlewares](https://github.com/NaumovOleg/heliosjs/tree/master/packages/middlewares) | Built-in middleware |
19
+ | [@heliosjs/aws](https://github.com/NaumovOleg/heliosjs/tree/master/packages/aws) | Aws support |
397
20
 
398
- ## Custom plugins.
399
-
400
- Use plugins to extend app with custom logic.
401
-
402
- Example server setup:
403
-
404
- ```typescript
405
- import { Server, HttpServer } from 'quantum-flow/http';
406
- import { User, UserMetadata } from './controllers';
407
- import client from 'prom-client';
408
-
409
- const register = new client.Registry();
410
- client.collectDefaultMetrics({ register });
411
-
412
- const httpRequestsTotal = new client.Counter({
413
- name: 'http_requests_total',
414
- help: 'Total number of HTTP requests',
415
- labelNames: ['method', 'path', 'status'],
416
- });
417
-
418
- @Controller({ prefix: 'metrics' })
419
- export class MetricsController {...}
420
- @Server({...})
421
- class App {}
422
-
423
- const server = new HttpServer(App);
424
- server.usePligun(metricsPlugin)
425
- server.listen().catch(console.error);
426
-
427
- // Lambda setup
428
- let connection;
429
- const dbConnectionPlugin: Plugin = {
430
- name: 'metric',
431
- beforeRequest: async(server) => {
432
- if(!connection){
433
- connection = await connetct(...)
434
- }
435
- },
436
- hooks: {...},
437
- };
438
-
439
- const lambdaAdapter = new LambdaAdapter(Root);
440
- lambdaAdapter.usePlugin(dbConnectionPlugin);
441
-
442
- export const handler = lambdaAdapter.handler;
443
- ```
444
-
445
- ## GraphQL
446
-
447
- Quantum Flow provides seamless GraphQL integration using the popular **TypeGraphQL** library. You can build fully typed GraphQL APIs with decorators, while the framework handles the server setup, subscriptions, and PubSub.
448
-
449
- ### Installation
21
+ ## Quick Start
450
22
 
451
23
  ```bash
452
- npm install type-graphql graphql graphql-yoga @graphql-yoga/subscriptions
453
- # or
454
- yarn add type-graphql graphql graphql-yoga @graphql-yoga/subscriptions
455
- ```
456
-
457
- ```typescript
458
- @Server({
459
- controllers: [/* your REST controllers */],
460
- graphql: { // GraphQL endpoint (default: '/graphql')
461
- path: '/graphql', // Enable GraphQL Playground
462
- resolvers: [UserResolver, MessageResolver], // Your resolver classes
463
- pubSub: pubSub, // Your PubSub instance (required for subscriptions)
464
- },
465
- })
466
- ```
467
-
468
- ## Usage example
469
-
470
- ```typescript
471
- import { IsEmail, MinLength } from 'class-validator';
472
- import {
473
- Arg,
474
- Ctx,
475
- Field,
476
- InputType,
477
- Mutation,
478
- ObjectType,
479
- Query,
480
- Resolver,
481
- Root,
482
- Subscription,
483
- } from 'type-graphql';
484
-
485
- import { createPubSub } from 'graphql-yoga';
486
-
487
- export type PubSubChannels = {
488
- NOTIFICATIONS: [{ id: string; userId: string; message: string }];
489
- USER_UPDATED: [{ user: User }];
490
- };
491
-
492
- export const pubSub = createPubSub<PubSubChannels>();
493
-
494
- @ObjectType()
495
- export class User {
496
- @Field()
497
- id: string;
498
- @Field()
499
- name: string;
500
- @Field()
501
- email: string;
502
- }
503
-
504
- @InputType()
505
- export class CreateUserInput {
506
- @Field()
507
- @MinLength(2)
508
- name: string;
509
- @Field()
510
- @IsEmail()
511
- email: string;
512
- }
513
-
514
- @Resolver()
515
- export class UserResolver {
516
- @Query(() => [User])
517
- async users(): Promise<User[]> {
518
- // pubSub.publish('USER_UPDATED', {...});
519
- return [];
520
- }
521
-
522
- @Mutation(() => User)
523
- async createUser(@Ctx() ctx: any, @Arg('input') input: CreateUserInput): Promise<User> {
524
- const user = {
525
- id: Date.now().toString(),
526
- ...input,
527
- };
528
-
529
- return user;
530
- }
531
-
532
- @Subscription(() => User, {
533
- topics: 'USER_UPDATED',
534
- filter: ({ payload, args }) => true,
535
- })
536
- newUser(@Root() user: User): User {
537
- return user;
538
- }
539
- }
24
+ npm install @heliosjs/core @heliosjs/http reflect-metadata
540
25
  ```
26
+ ````
@@ -9,7 +9,7 @@
9
9
  * @Body(UserDto) user: UserDto
10
10
  * ```
11
11
  */
12
- export declare const Body: (dto?: any) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
12
+ export declare const Body: (dto?: unknown) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
13
13
  /**
14
14
  * Parameter decorator to extract route parameters.
15
15
  *
@@ -23,7 +23,7 @@ export declare const Body: (dto?: any) => (target: any, propertyKey: string | sy
23
23
  * @Params(UserParamsDto) params: UserParamsDto
24
24
  * ```
25
25
  */
26
- export declare const Params: (dto?: any, name?: string) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
26
+ export declare const Params: (dto?: unknown, name?: string) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
27
27
  /**
28
28
  * Parameter decorator to extract query parameters.
29
29
  *
@@ -37,7 +37,7 @@ export declare const Params: (dto?: any, name?: string) => (target: any, propert
37
37
  * @Query(SearchDto) query: SearchDto
38
38
  * ```
39
39
  */
40
- export declare const Query: (dto?: any, name?: string) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
40
+ export declare const Query: (dto?: unknown, name?: string) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
41
41
  /**
42
42
  * Parameter decorator to inject the entire request object.
43
43
  *
@@ -28,7 +28,7 @@ exports.Body = Body;
28
28
  * @Params(UserParamsDto) params: UserParamsDto
29
29
  * ```
30
30
  */
31
- const Params = (dto, name) => (0, core_1.createParamDecorator)('params', typeof dto == 'string' ? undefined : dto, (name ?? typeof dto == 'string') ? dto : name);
31
+ const Params = (dto, name) => (0, core_1.createParamDecorator)('params', typeof dto == 'string' ? undefined : dto, typeof dto == 'string' ? dto : name);
32
32
  exports.Params = Params;
33
33
  /**
34
34
  * Parameter decorator to extract query parameters.
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AAEpD;;;;;;;;;;GAUG;AACI,MAAM,IAAI,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,IAAA,2BAAoB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAAxD,QAAA,IAAI,QAAoD;AAErE;;;;;;;;;;;;GAYG;AACI,MAAM,MAAM,GAAG,CAAC,GAAS,EAAE,IAAa,E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OAAO,WAAuE;AAE3F;;;;;;;;;;GAUG;AACI,MAAM,OAAO,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,IAAA,2BAAoB,EAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AAA9E,QAAA,OAAO,WAAuE;AAE3F;;;;;;;;;;GAUG;AACI,MAAM,KAAK,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,IAAA,2BAAoB,EAAC,WAAW,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AAA9E,QAAA,KAAK,SAAyE;AAE3F;;;;;;;GAOG;AACI,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,IAAA,2BAAoB,EAAC,UAAU,CAAC,CAAC;AAA7C,QAAA,GAAG,OAA0C"}
package/dist/index.d.ts CHANGED
@@ -7,5 +7,5 @@
7
7
  export * from './Controller';
8
8
  export * from './decorators';
9
9
  export * from './Endpoint';
10
- export { AppError, CORSConfig, ErrorCB, InterceptorCB, MiddlewareCB, MultipartFile, Request, Response, SanitizerConfig, } from './types/core';
10
+ export { CORSConfig, ErrorCB, HeliosError, InterceptorCB, MiddlewareCB, MultipartFile, Request, Response, SanitizerConfig, } from './types/core';
11
11
  export { SANITIZER } from './utils/core';
@@ -1,28 +1,28 @@
1
1
  import { ServerResponse } from 'http';
2
- import { AppError } from './error';
2
+ import { HeliosError } from './error';
3
3
  import { Request } from './request';
4
4
  import { Response } from './response';
5
5
  export type Router = (req: Request, res?: ServerResponse) => Promise<{
6
6
  status: number;
7
- data: any;
7
+ data: unknown;
8
8
  message?: string;
9
9
  }>;
10
10
  export interface IController {
11
11
  handleRequest: Router;
12
12
  }
13
- export type MiddlewareCB = (request: Request, response: Response, next: (args?: any) => any) => void | Promise<Request> | Request | Promise<void> | void;
14
- export type InterceptorCB = (data: any, req?: Request, res?: Response) => Promise<unknown> | unknown;
15
- export type ErrorCB = (error: AppError, req?: Request, res?: Response) => any;
13
+ export type MiddlewareCB = (request: Request, response: Response, next: (err?: HeliosError) => Promise<any> | any) => void | Promise<Request> | Request | Promise<void> | void;
14
+ export type InterceptorCB = (data: unknown, req?: Request, res?: Response) => Promise<unknown> | unknown;
15
+ export type ErrorCB = (error: HeliosError, req?: Request, res?: Response) => unknown;
16
16
  export type ParamDecoratorType = 'body' | 'params' | 'query' | 'request' | 'headers' | 'cookies' | 'response' | 'multipart' | 'event' | 'context' | 'sse' | 'ws';
17
17
  export interface ParamMetadata {
18
18
  index: number;
19
19
  type: ParamDecoratorType;
20
- dto?: any;
20
+ dto?: unknown;
21
21
  name?: string;
22
22
  }
23
23
  export type ResponseWithStatus = {
24
24
  status: number;
25
- [key: string]: any;
25
+ [key: string]: unknown;
26
26
  };
27
27
  export declare enum HTTP_METHODS {
28
28
  ANY = "ANY",