@grupodiariodaregiao/bunstone 0.0.27
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/README.md +91 -0
- package/bin/cli.ts +182 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +4316 -0
- package/dist/lib/adapters/cache-adapter.d.ts +19 -0
- package/dist/lib/adapters/form-data.d.ts +4 -0
- package/dist/lib/adapters/upload-adapter.d.ts +22 -0
- package/dist/lib/app-startup.d.ts +76 -0
- package/dist/lib/components/layout.d.ts +8 -0
- package/dist/lib/constants/index.d.ts +1 -0
- package/dist/lib/controller.d.ts +14 -0
- package/dist/lib/cqrs/command-bus.d.ts +19 -0
- package/dist/lib/cqrs/cqrs-module.d.ts +2 -0
- package/dist/lib/cqrs/decorators/command-handler.decorator.d.ts +7 -0
- package/dist/lib/cqrs/decorators/event-handler.decorator.d.ts +7 -0
- package/dist/lib/cqrs/decorators/query-handler.decorator.d.ts +7 -0
- package/dist/lib/cqrs/decorators/saga.decorator.d.ts +7 -0
- package/dist/lib/cqrs/event-bus.d.ts +38 -0
- package/dist/lib/cqrs/interfaces/command.interface.d.ts +5 -0
- package/dist/lib/cqrs/interfaces/event.interface.d.ts +5 -0
- package/dist/lib/cqrs/interfaces/query.interface.d.ts +5 -0
- package/dist/lib/cqrs/query-bus.d.ts +19 -0
- package/dist/lib/database/sql-module.d.ts +25 -0
- package/dist/lib/guard.d.ts +8 -0
- package/dist/lib/http-exceptions.d.ts +73 -0
- package/dist/lib/http-methods.d.ts +36 -0
- package/dist/lib/http-params.d.ts +28 -0
- package/dist/lib/injectable.d.ts +12 -0
- package/dist/lib/interfaces/class-constructor.d.ts +6 -0
- package/dist/lib/interfaces/guard-contract.d.ts +7 -0
- package/dist/lib/jwt/jwt-module.d.ts +13 -0
- package/dist/lib/jwt.d.ts +5 -0
- package/dist/lib/module.d.ts +18 -0
- package/dist/lib/openapi.d.ts +52 -0
- package/dist/lib/render.d.ts +7 -0
- package/dist/lib/schedule/cron/cron.d.ts +7 -0
- package/dist/lib/schedule/cron/mappers/map-providers-with-cron.d.ts +8 -0
- package/dist/lib/schedule/timeout/mappers/map-providers-with-timeouts.d.ts +9 -0
- package/dist/lib/schedule/timeout/timeout.d.ts +7 -0
- package/dist/lib/types/http-request.d.ts +13 -0
- package/dist/lib/types/module-config.d.ts +14 -0
- package/dist/lib/types/options.d.ts +24 -0
- package/dist/lib/utils/colors.d.ts +36 -0
- package/dist/lib/utils/dependency-injection.d.ts +25 -0
- package/dist/lib/utils/is-class.d.ts +1 -0
- package/dist/lib/utils/is-zod-schema.d.ts +2 -0
- package/dist/lib/utils/logger.d.ts +38 -0
- package/dist/lib/utils/map-providers.d.ts +14 -0
- package/package.json +47 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type CacheValue = Record<string, unknown>;
|
|
2
|
+
export type CacheSetOptions = {
|
|
3
|
+
permanent: true;
|
|
4
|
+
} | {
|
|
5
|
+
ttlSeconds: number;
|
|
6
|
+
} | {
|
|
7
|
+
ttl: number;
|
|
8
|
+
};
|
|
9
|
+
export type CacheAdapterConfig = {
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class CacheAdapter {
|
|
13
|
+
private readonly client;
|
|
14
|
+
constructor(config?: CacheAdapterConfig);
|
|
15
|
+
set(key: string, value: CacheValue, options?: CacheSetOptions): Promise<void>;
|
|
16
|
+
get<T extends CacheValue>(key: string): Promise<T>;
|
|
17
|
+
exists(key: string): Promise<boolean>;
|
|
18
|
+
remove(key: string): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { S3Client, type S3Options } from "bun";
|
|
2
|
+
import "reflect-metadata";
|
|
3
|
+
export type S3UploadBody = Parameters<S3Client["write"]>[1];
|
|
4
|
+
export type MinioConfig = {
|
|
5
|
+
endpoint: string;
|
|
6
|
+
accessKey: string;
|
|
7
|
+
secretKey: string;
|
|
8
|
+
bucket: string;
|
|
9
|
+
};
|
|
10
|
+
export type S3UploadParams = {
|
|
11
|
+
path: string;
|
|
12
|
+
body: S3UploadBody;
|
|
13
|
+
contentType?: string;
|
|
14
|
+
acl?: S3Options["acl"];
|
|
15
|
+
};
|
|
16
|
+
export declare class UploadAdatper {
|
|
17
|
+
private readonly client;
|
|
18
|
+
constructor(config?: MinioConfig);
|
|
19
|
+
upload(params: S3UploadParams): Promise<string>;
|
|
20
|
+
exists(path: string): Promise<boolean>;
|
|
21
|
+
remove(path: string): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import Elysia from "elysia";
|
|
2
|
+
import "reflect-metadata";
|
|
3
|
+
import type { Options } from "./types/options";
|
|
4
|
+
/**
|
|
5
|
+
* Main entry point for the Bunstone application.
|
|
6
|
+
* Handles module registration, route setup, and server startup.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AppStartup {
|
|
9
|
+
private static elysia;
|
|
10
|
+
private static readonly logger;
|
|
11
|
+
private static readonly registeredSagas;
|
|
12
|
+
private static readonly viewBundles;
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the application from a root module.
|
|
15
|
+
*
|
|
16
|
+
* @param module The root module of the application.
|
|
17
|
+
* @param options Optional configuration (e.g., CORS).
|
|
18
|
+
* @returns An object with a `listen` method to start the server.
|
|
19
|
+
*/
|
|
20
|
+
static create(module: any, options?: Options): {
|
|
21
|
+
/**
|
|
22
|
+
* Starts the server on the specified port.
|
|
23
|
+
* @param port The port number to listen on.
|
|
24
|
+
*/
|
|
25
|
+
listen: typeof AppStartup.listen;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the underlying Elysia instance.
|
|
28
|
+
*/
|
|
29
|
+
getElysia: () => Elysia<"", {
|
|
30
|
+
decorator: {};
|
|
31
|
+
store: {};
|
|
32
|
+
derive: {};
|
|
33
|
+
resolve: {};
|
|
34
|
+
}, {
|
|
35
|
+
typebox: {};
|
|
36
|
+
error: {};
|
|
37
|
+
}, {
|
|
38
|
+
schema: {};
|
|
39
|
+
standaloneSchema: {};
|
|
40
|
+
macro: {};
|
|
41
|
+
macroFn: {};
|
|
42
|
+
parser: {};
|
|
43
|
+
response: {};
|
|
44
|
+
}, {}, {
|
|
45
|
+
derive: {};
|
|
46
|
+
resolve: {};
|
|
47
|
+
schema: {};
|
|
48
|
+
standaloneSchema: {};
|
|
49
|
+
response: {};
|
|
50
|
+
}, {
|
|
51
|
+
derive: {};
|
|
52
|
+
resolve: {};
|
|
53
|
+
schema: {};
|
|
54
|
+
standaloneSchema: {};
|
|
55
|
+
response: {};
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Bundles a client-side component for hydration (internal).
|
|
60
|
+
*/
|
|
61
|
+
private static bundle;
|
|
62
|
+
private static autoBundle;
|
|
63
|
+
/**
|
|
64
|
+
* Starts the server on the specified port.
|
|
65
|
+
* @param port The port number to listen on.
|
|
66
|
+
*/
|
|
67
|
+
static listen(port: number): void;
|
|
68
|
+
private static executeControllerMethod;
|
|
69
|
+
private static registerModules;
|
|
70
|
+
private static registerRoutes;
|
|
71
|
+
private static registerTimeouts;
|
|
72
|
+
private static registerCronJobs;
|
|
73
|
+
private static registerCqrsHandlers;
|
|
74
|
+
private static startWithJWT;
|
|
75
|
+
private static getControllerHandler;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PARAM_METADATA_KEY: unique symbol;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that marks a class as an HTTP controller.
|
|
4
|
+
* Controllers are responsible for handling incoming requests and returning responses.
|
|
5
|
+
*
|
|
6
|
+
* @param pathname The base path for all routes defined within this controller. Defaults to "/".
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* @Controller('users')
|
|
11
|
+
* export class UserController {}
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function Controller(pathname?: string): any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ICommand, ICommandHandler } from "./interfaces/command.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Bus for dispatching commands to their respective handlers.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CommandBus {
|
|
6
|
+
private handlers;
|
|
7
|
+
/**
|
|
8
|
+
* Registers a list of command handlers.
|
|
9
|
+
* @param handlers Array of command handler instances.
|
|
10
|
+
*/
|
|
11
|
+
register(handlers: ICommandHandler[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Executes a command and returns the result.
|
|
14
|
+
* @param command The command instance to execute.
|
|
15
|
+
* @returns The result of the command execution.
|
|
16
|
+
* @throws Error if no handler is found for the command.
|
|
17
|
+
*/
|
|
18
|
+
execute<T extends ICommand, R = any>(command: T): Promise<R>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const COMMAND_HANDLER_METADATA = "dip:cqrs:command-handler";
|
|
3
|
+
/**
|
|
4
|
+
* Decorator that marks a class as a command handler.
|
|
5
|
+
* @param command The command class that this handler handles.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CommandHandler: (command: any) => any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const EVENT_HANDLER_METADATA = "dip:cqrs:event-handler";
|
|
3
|
+
/**
|
|
4
|
+
* Decorator that marks a class as an event handler.
|
|
5
|
+
* @param events The event classes that this handler handles.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EventsHandler: (...events: any[]) => any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const QUERY_HANDLER_METADATA = "dip:cqrs:query-handler";
|
|
3
|
+
/**
|
|
4
|
+
* Decorator that marks a class as a query handler.
|
|
5
|
+
* @param query The query class that this handler handles.
|
|
6
|
+
*/
|
|
7
|
+
export declare const QueryHandler: (query: any) => any;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { IEvent, IEventHandler } from "./interfaces/event.interface";
|
|
2
|
+
export type IEventStream = {
|
|
3
|
+
pipe: (...operators: any[]) => IEventStream;
|
|
4
|
+
subscribe: (callback: (event: IEvent) => void) => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Bus for publishing and subscribing to events.
|
|
8
|
+
* Supports event handlers and reactive streams (Sagas).
|
|
9
|
+
*/
|
|
10
|
+
export declare class EventBus {
|
|
11
|
+
private handlers;
|
|
12
|
+
private listeners;
|
|
13
|
+
/**
|
|
14
|
+
* Registers a list of event handlers.
|
|
15
|
+
* @param handlers Array of event handler instances.
|
|
16
|
+
*/
|
|
17
|
+
register(handlers: IEventHandler[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* Publishes an event to all registered handlers and listeners.
|
|
20
|
+
* @param event The event instance to publish.
|
|
21
|
+
*/
|
|
22
|
+
publish<T extends IEvent>(event: T): void;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a stream of events for reactive processing.
|
|
25
|
+
* Used primarily by Sagas.
|
|
26
|
+
*/
|
|
27
|
+
get stream(): IEventStream;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Filters events by type in a Saga stream.
|
|
31
|
+
* @param types The event classes to filter by.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ofType: (...types: any[]) => (event: IEvent, next: (event: IEvent) => void) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Transforms events in a Saga stream.
|
|
36
|
+
* @param fn The transformation function.
|
|
37
|
+
*/
|
|
38
|
+
export declare const map: (fn: (event: any) => any) => (event: IEvent, next: (result: any) => void) => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IQuery, IQueryHandler } from "./interfaces/query.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Bus for dispatching queries to their respective handlers.
|
|
4
|
+
*/
|
|
5
|
+
export declare class QueryBus {
|
|
6
|
+
private handlers;
|
|
7
|
+
/**
|
|
8
|
+
* Registers a list of query handlers.
|
|
9
|
+
* @param handlers Array of query handler instances.
|
|
10
|
+
*/
|
|
11
|
+
register(handlers: IQueryHandler[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Executes a query and returns the result.
|
|
14
|
+
* @param query The query instance to execute.
|
|
15
|
+
* @returns The result of the query execution.
|
|
16
|
+
* @throws Error if no handler is found for the query.
|
|
17
|
+
*/
|
|
18
|
+
execute<T extends IQuery, R = any>(query: T): Promise<R>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SQL } from "bun";
|
|
2
|
+
type ConnectionOptions = {
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
database: string;
|
|
8
|
+
provider: "postgresql" | "mysql" | "sqlite";
|
|
9
|
+
};
|
|
10
|
+
export declare class SqlService {
|
|
11
|
+
query<T = any>(query: string, params?: any[]): Promise<T[]>;
|
|
12
|
+
transaction(queries: Array<{
|
|
13
|
+
query: string;
|
|
14
|
+
params?: any[];
|
|
15
|
+
}>): Promise<void>;
|
|
16
|
+
bulkInsert<T = any>(table: string, values: T[]): Promise<void>;
|
|
17
|
+
private getSqlInstance;
|
|
18
|
+
}
|
|
19
|
+
export declare class SqlModule {
|
|
20
|
+
private static sqlInstance;
|
|
21
|
+
static register(connection: ConnectionOptions): typeof SqlModule;
|
|
22
|
+
static register(connection: string): typeof SqlModule;
|
|
23
|
+
static getSqlInstance(): SQL;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import type { ClassConstructor } from "./interfaces/class-constructor";
|
|
3
|
+
/**
|
|
4
|
+
* Decorator to define a guard class.
|
|
5
|
+
* @param guard The guard class constructor.
|
|
6
|
+
* @returns A class or method decorator.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Guard(guard: ClassConstructor): any;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all HTTP exceptions.
|
|
3
|
+
*/
|
|
4
|
+
export declare class HttpException extends Error {
|
|
5
|
+
readonly response: string | object;
|
|
6
|
+
readonly status: number;
|
|
7
|
+
constructor(response: string | object, status: number);
|
|
8
|
+
getResponse(): string | object;
|
|
9
|
+
getStatus(): number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 400 Bad Request Exception
|
|
13
|
+
*/
|
|
14
|
+
export declare class BadRequestException extends HttpException {
|
|
15
|
+
constructor(response?: string | object);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 401 Unauthorized Exception
|
|
19
|
+
*/
|
|
20
|
+
export declare class UnauthorizedException extends HttpException {
|
|
21
|
+
constructor(response?: string | object);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 403 Forbidden Exception
|
|
25
|
+
*/
|
|
26
|
+
export declare class ForbiddenException extends HttpException {
|
|
27
|
+
constructor(response?: string | object);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 404 Not Found Exception
|
|
31
|
+
*/
|
|
32
|
+
export declare class NotFoundException extends HttpException {
|
|
33
|
+
constructor(response?: string | object);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 409 Conflict Exception
|
|
37
|
+
*/
|
|
38
|
+
export declare class ConflictException extends HttpException {
|
|
39
|
+
constructor(response?: string | object);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 422 Unprocessable Entity Exception
|
|
43
|
+
*/
|
|
44
|
+
export declare class UnprocessableEntityException extends HttpException {
|
|
45
|
+
constructor(response?: string | object);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 500 Internal Server Error Exception
|
|
49
|
+
*/
|
|
50
|
+
export declare class InternalServerErrorException extends HttpException {
|
|
51
|
+
constructor(response?: string | object);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Success "Exceptions" (can be thrown to exit early with a specific status)
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* 200 OK
|
|
58
|
+
*/
|
|
59
|
+
export declare class OkResponse extends HttpException {
|
|
60
|
+
constructor(response?: string | object);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 201 Created
|
|
64
|
+
*/
|
|
65
|
+
export declare class CreatedResponse extends HttpException {
|
|
66
|
+
constructor(response?: string | object);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 204 No Content
|
|
70
|
+
*/
|
|
71
|
+
export declare class NoContentResponse extends HttpException {
|
|
72
|
+
constructor();
|
|
73
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
/**
|
|
3
|
+
* Route decorator for GET requests.
|
|
4
|
+
* @param pathname Optional path for the route.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Get(pathname?: string): any;
|
|
7
|
+
/**
|
|
8
|
+
* Route decorator for POST requests.
|
|
9
|
+
* @param pathname Optional path for the route.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Post(pathname?: string): any;
|
|
12
|
+
/**
|
|
13
|
+
* Route decorator for PUT requests.
|
|
14
|
+
* @param pathname Optional path for the route.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Put(pathname?: string): any;
|
|
17
|
+
/**
|
|
18
|
+
* Route decorator for DELETE requests.
|
|
19
|
+
* @param pathname Optional path for the route.
|
|
20
|
+
*/
|
|
21
|
+
export declare function Delete(pathname?: string): any;
|
|
22
|
+
/**
|
|
23
|
+
* Route decorator for PATCH requests.
|
|
24
|
+
* @param pathname Optional path for the route.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Patch(pathname?: string): any;
|
|
27
|
+
/**
|
|
28
|
+
* Route decorator for OPTIONS requests.
|
|
29
|
+
* @param pathname Optional path for the route.
|
|
30
|
+
*/
|
|
31
|
+
export declare function Options(pathname?: string): any;
|
|
32
|
+
/**
|
|
33
|
+
* Route decorator for HEAD requests.
|
|
34
|
+
* @param pathname Optional path for the route.
|
|
35
|
+
*/
|
|
36
|
+
export declare function Head(pathname?: string): any;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { type ZodType } from "zod/v4";
|
|
3
|
+
export declare enum ParamType {
|
|
4
|
+
BODY = "body",
|
|
5
|
+
QUERY = "query",
|
|
6
|
+
PARAM = "param",
|
|
7
|
+
HEADER = "header",
|
|
8
|
+
REQUEST = "request",
|
|
9
|
+
FORM_DATA = "form-data"
|
|
10
|
+
}
|
|
11
|
+
export declare function Body(schema?: ZodType): any;
|
|
12
|
+
export declare function Param(schema?: ZodType): any;
|
|
13
|
+
export declare function Param(key?: string): any;
|
|
14
|
+
export declare function Query(schema?: ZodType): any;
|
|
15
|
+
export declare function Query(key?: string): any;
|
|
16
|
+
export declare function Header(key: string): any;
|
|
17
|
+
export declare function Request(): any;
|
|
18
|
+
export declare function processParameters(request: any, target: any, propertyKey: string): Promise<any[]>;
|
|
19
|
+
export type FormDataOptions = {
|
|
20
|
+
fileField?: string;
|
|
21
|
+
allowedTypes?: string[];
|
|
22
|
+
jsonField?: string;
|
|
23
|
+
};
|
|
24
|
+
export type FormDataFields = Record<string, string | string[]>;
|
|
25
|
+
export type FormDataPayload = {
|
|
26
|
+
files: File[];
|
|
27
|
+
json?: unknown;
|
|
28
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that marks a class as available to be injected as a dependency.
|
|
4
|
+
* Classes decorated with `@Injectable()` can be managed by the Bunstone DI container.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* @Injectable()
|
|
9
|
+
* export class UserService {}
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function Injectable(): any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HttpRequest } from "../types/http-request";
|
|
2
|
+
/** Interface for a guard contract that validates HTTP requests.
|
|
3
|
+
* @property validate(req: HttpRequest): boolean | Promise<boolean> - Method to validate an HTTP request, returning a boolean or a Promise that resolves to a boolean.
|
|
4
|
+
*/
|
|
5
|
+
export interface GuardContract {
|
|
6
|
+
validate(req: HttpRequest): boolean | Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JWTOption } from "@elysiajs/jwt";
|
|
2
|
+
import "reflect-metadata";
|
|
3
|
+
/**
|
|
4
|
+
* Module for configuring JWT authentication.
|
|
5
|
+
*/
|
|
6
|
+
export declare class JwtModule {
|
|
7
|
+
private static options;
|
|
8
|
+
/**
|
|
9
|
+
* Configures the JWT options for the application.
|
|
10
|
+
* @param options JWT configuration options (secret, algorithm, expiration, etc.).
|
|
11
|
+
*/
|
|
12
|
+
static register(options: JWTOption): typeof JwtModule;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import type { ModuleConfig } from "./types/module-config";
|
|
3
|
+
/**
|
|
4
|
+
* Decorator that marks a class as a module.
|
|
5
|
+
* Modules are used to organize the application structure and manage dependency injection scopes.
|
|
6
|
+
*
|
|
7
|
+
* @param moduleConfig Configuration object defining controllers, providers, imports, and exports.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Module({
|
|
12
|
+
* controllers: [AppController],
|
|
13
|
+
* providers: [AppService],
|
|
14
|
+
* })
|
|
15
|
+
* export class AppModule {}
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function Module(moduleConfig?: ModuleConfig): any;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const API_TAGS_METADATA = "dip:openapi:tags";
|
|
3
|
+
export declare const API_OPERATION_METADATA = "dip:openapi:operation";
|
|
4
|
+
export declare const API_RESPONSE_METADATA = "dip:openapi:responses";
|
|
5
|
+
export declare const API_HEADERS_METADATA = "dip:openapi:headers";
|
|
6
|
+
/**
|
|
7
|
+
* Decorator that adds tags to a controller or method for OpenAPI.
|
|
8
|
+
* @param tags List of tags.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ApiTags(...tags: string[]): any;
|
|
11
|
+
/**
|
|
12
|
+
* Decorator that defines an operation summary and description for OpenAPI.
|
|
13
|
+
* @param options Operation options.
|
|
14
|
+
* @param options.summary A short summary of what the operation does.
|
|
15
|
+
* @param options.description A verbose explanation of the operation behavior.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ApiOperation(options: {
|
|
18
|
+
summary?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
}): any;
|
|
21
|
+
/**
|
|
22
|
+
* Decorator that defines a response for OpenAPI.
|
|
23
|
+
* @param options Response options.
|
|
24
|
+
* @param options.status The HTTP status code.
|
|
25
|
+
* @param options.description A short description of the response.
|
|
26
|
+
* @param options.type Optional Zod schema or type for the response body.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ApiResponse(options: {
|
|
29
|
+
status: number;
|
|
30
|
+
description: string;
|
|
31
|
+
type?: any;
|
|
32
|
+
}): any;
|
|
33
|
+
/**
|
|
34
|
+
* Decorator that defines a header for OpenAPI.
|
|
35
|
+
* @param options Header options.
|
|
36
|
+
*/
|
|
37
|
+
export declare function ApiHeader(options: {
|
|
38
|
+
name: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
schema?: any;
|
|
42
|
+
}): any;
|
|
43
|
+
/**
|
|
44
|
+
* Decorator that defines multiple headers for OpenAPI.
|
|
45
|
+
* @param headers List of header options.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ApiHeaders(headers: {
|
|
48
|
+
name: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
required?: boolean;
|
|
51
|
+
schema?: any;
|
|
52
|
+
}[]): (target: any, propertyKey?: string | symbol) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const RENDER_METADATA = "dip:render:component";
|
|
3
|
+
/**
|
|
4
|
+
* Decorator to specify a React component to render the controller's response.
|
|
5
|
+
* @param component The React component to use as a View.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Render(component: any): any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import type { ModuleConfig } from "../../../types/module-config";
|
|
3
|
+
export declare class MapProvidersWithTimeout {
|
|
4
|
+
static execute(providers?: ModuleConfig["providers"]): Map<any, {
|
|
5
|
+
expression?: string;
|
|
6
|
+
delay?: number;
|
|
7
|
+
methodName: string;
|
|
8
|
+
}[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HTTPHeaders, RouteSchema } from "elysia";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an HTTP request with headers and optional JWT methods.
|
|
4
|
+
* @property headers - The HTTP headers of the request.
|
|
5
|
+
* @property jwt - Optional JWT methods for signing and verifying tokens.
|
|
6
|
+
*/
|
|
7
|
+
export type HttpRequest = RouteSchema & {
|
|
8
|
+
headers: HTTPHeaders;
|
|
9
|
+
jwt?: {
|
|
10
|
+
sign(payload: Record<string, any>): Promise<string>;
|
|
11
|
+
verify(token?: string): Promise<false | Record<string, any>>;
|
|
12
|
+
};
|
|
13
|
+
};
|