balda 0.0.35 → 0.0.38

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/lib/index.d.cts CHANGED
@@ -1453,6 +1453,7 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
1453
1453
  mountExpressRouter(basePath: string, expressRouter: Router$1): void;
1454
1454
  setErrorHandler(errorHandler?: ServerErrorHandler): void;
1455
1455
  setNotFoundHandler(notFoundHandler?: ServerRouteHandler): void;
1456
+ beforeStart(hook: ServerHook): void;
1456
1457
  listen(cb?: ServerListenCallback): void;
1457
1458
  waitUntilListening(): Promise<void>;
1458
1459
  /**
@@ -2269,6 +2270,18 @@ interface ServerInterface {
2269
2270
  * });
2270
2271
  */
2271
2272
  setNotFoundHandler: (notFoundHandler?: ServerRouteHandler) => void;
2273
+ /**
2274
+ * Register a hook to be called after bootstrap (controllers imported, plugins applied) but before the server starts accepting requests.
2275
+ * Multiple hooks are called in the order they are registered.
2276
+ * @param hook - The hook function to call, can be sync or async
2277
+ * @example
2278
+ * ```ts
2279
+ * server.beforeStart(async () => {
2280
+ * await connectToDatabase();
2281
+ * });
2282
+ * ```
2283
+ */
2284
+ beforeStart: (hook: ServerHook) => void;
2272
2285
  /**
2273
2286
  * Binds the server to the port and hostname defined in the serverOptions, meant to be called only once
2274
2287
  * It initializes the server without blocking the event loop, you can pass a callback to be called when the server is listening
@@ -2332,6 +2345,7 @@ type StandardMethodOptions = {
2332
2345
  all?: RequestSchema;
2333
2346
  swagger?: SwaggerRouteOptions;
2334
2347
  };
2348
+ type ServerHook = () => SyncOrAsync;
2335
2349
  type SignalEvent = Deno.Signal | NodeJS.Signals;
2336
2350
  type ControllerHandler<TPath extends string = string> = (req: Request<ExtractParams<TPath>>, res: Response$1, ...args: any[]) => ServerHandlerReturnType;
2337
2351
 
@@ -3191,6 +3205,8 @@ declare class CommandRegistry {
3191
3205
  private constructor();
3192
3206
  static getInstance(): CommandRegistry;
3193
3207
  static setCommandsPattern(pattern: string): void;
3208
+ getLogger(): Logger<string, boolean>;
3209
+ setLogger(logger: Logger): void;
3194
3210
  getCommand(name: string): typeof Command | null;
3195
3211
  getCommands(): (typeof Command)[];
3196
3212
  getBuiltInCommands(): (typeof Command)[];
@@ -4058,4 +4074,4 @@ declare const createPolicyDecorator: <T extends Record<string, PolicyProvider>>(
4058
4074
  */
4059
4075
  declare const router: ClientRouter;
4060
4076
 
4061
- export { type AsyncLocalStorageContextSetters, AzureBlobStorageProvider, BaseCron, BasePlugin, type BaseStorageProviderOptions, type BlobStorageProviderOptions, BullMQConfiguration, type BullMQConfigurationOptions, BullMQPubSub, Command, type CommandOptions, CommandRegistry, type CompressionOptions, type CookieMiddlewareOptions, type CorsOptions, type CronSchedule, type CronScheduleParams, CronService, type CronUIOptions, CustomAdapter, type CustomQueueConfiguration, type CustomStorageProviderOptions, CustomTypedQueue, type CustomValidationError, EdgeAdapter, EjsAdapter, type ExtractParams, GraphQL, type GraphQLContext, type GraphQLOptions, type GraphQLResolverFunction, type GraphQLResolverMap, type GraphQLResolverType, type GraphQLResolvers, type GraphQLSchemaInput, type GraphQLTypeDef, HandlebarsAdapter, type HelmetOptions, type HttpMethod, type HttpsOptions, type InferSchemaType, LocalStorageProvider, type LocalStorageProviderOptions, type LogOptions, type LoggerOptions, type MailOptions, MailOptionsBuilder, MailProvider, type MailProviderInterface, Mailer, type MailerInterface, type MailerOptions, type MailerProviderOptions, MemoryPubSub, type MethodOverrideOptions, MockResponse, MockServer, type MockServerOptions, type MqttConnectionOptions, type MqttHandler, type MqttPublishOptions, MqttService, type MqttSubscribeOptions, type MqttSubscription, type MqttTopics, MustacheAdapter, type NextFunction, type NodeHttpClient, type NodeServer as NodeHttpServerClient, PGBossConfiguration, type PGBossConfigurationOptions, PGBossPubSub, type PolicyDecorator, PolicyManager, type PolicyProvider, type PublishTopic, QueueManager, QueueService, type RateLimiterKeyOptions, Request, type RequestSchema, Response$1 as Response, type RuntimeServer, S3StorageProvider, type S3StorageProviderOptions, SQSConfiguration, type SQSConfigurationOptions, SQSPubSub, type CacheMetrics as SchemaCacheMetrics, type SerializeOptions, Server, type ServerConnectInput, type ServerErrorHandler, type ServerInterface, type ServerListenCallback, type ServerOptions, type ServerRouteHandler, type ServerRouteMiddleware, type ServerTapOptions, type SessionOptions, type SignalEvent, type StaticPluginOptions, Storage, type StorageInterface, type StorageOptions, type StorageProviderOptions, type TemplateMailOptions, type TimeoutOptions, type TrustProxyOptions, type TypedHandler, TypedQueue, type TypedRouteMetadata, type ValidatedData, type ValidationOptions, arg, asyncLocalStorage, asyncStorage, bullmqQueue, clearAllCaches as clearAllSchemaCaches, commandRegistry, compression, controller, cookie, cors, createExpressAdapter, createPolicyDecorator, createQueue, cron, Server as default, defineQueueConfiguration, del, expressHandler, expressMiddleware, flag, get, getCacheMetrics as getSchemaCacheMetrics, hash, helmet, log, logCacheMetrics as logSchemaCacheMetrics, logger, memoryQueue, methodOverride, middleware, mountExpressRouter, mqtt, patch, pgbossQueue, post, put, rateLimiter, router, serialize, serveStatic, session, setCronGlobalErrorHandler, setMqttGlobalErrorHandler, sqsQueue, timeout as timeoutMw, trustProxy, validate };
4077
+ export { type AsyncLocalStorageContextSetters, AzureBlobStorageProvider, BaseCron, BasePlugin, type BaseStorageProviderOptions, type BlobStorageProviderOptions, BullMQConfiguration, type BullMQConfigurationOptions, BullMQPubSub, Command, type CommandOptions, CommandRegistry, type CompressionOptions, type CookieMiddlewareOptions, type CorsOptions, type CronSchedule, type CronScheduleParams, CronService, type CronUIOptions, CustomAdapter, type CustomQueueConfiguration, type CustomStorageProviderOptions, CustomTypedQueue, type CustomValidationError, EdgeAdapter, EjsAdapter, type ExtractParams, GraphQL, type GraphQLContext, type GraphQLOptions, type GraphQLResolverFunction, type GraphQLResolverMap, type GraphQLResolverType, type GraphQLResolvers, type GraphQLSchemaInput, type GraphQLTypeDef, HandlebarsAdapter, type HelmetOptions, type HttpMethod, type HttpsOptions, type InferSchemaType, LocalStorageProvider, type LocalStorageProviderOptions, type LogOptions, type LoggerOptions, type MailOptions, MailOptionsBuilder, MailProvider, type MailProviderInterface, Mailer, type MailerInterface, type MailerOptions, type MailerProviderOptions, MemoryPubSub, type MethodOverrideOptions, MockResponse, MockServer, type MockServerOptions, type MqttConnectionOptions, type MqttHandler, type MqttPublishOptions, MqttService, type MqttSubscribeOptions, type MqttSubscription, type MqttTopics, MustacheAdapter, type NextFunction, type NodeHttpClient, type NodeServer as NodeHttpServerClient, PGBossConfiguration, type PGBossConfigurationOptions, PGBossPubSub, type PolicyDecorator, PolicyManager, type PolicyProvider, type PublishTopic, QueueManager, QueueService, type RateLimiterKeyOptions, Request, type RequestSchema, Response$1 as Response, type RuntimeServer, S3StorageProvider, type S3StorageProviderOptions, SQSConfiguration, type SQSConfigurationOptions, SQSPubSub, type CacheMetrics as SchemaCacheMetrics, type SerializeOptions, Server, type ServerConnectInput, type ServerErrorHandler, type ServerHook, type ServerInterface, type ServerListenCallback, type ServerOptions, type ServerRouteHandler, type ServerRouteMiddleware, type ServerTapOptions, type SessionOptions, type SignalEvent, type StaticPluginOptions, Storage, type StorageInterface, type StorageOptions, type StorageProviderOptions, type TemplateMailOptions, type TimeoutOptions, type TrustProxyOptions, type TypedHandler, TypedQueue, type TypedRouteMetadata, type ValidatedData, type ValidationOptions, arg, asyncLocalStorage, asyncStorage, bullmqQueue, clearAllCaches as clearAllSchemaCaches, commandRegistry, compression, controller, cookie, cors, createExpressAdapter, createPolicyDecorator, createQueue, cron, Server as default, defineQueueConfiguration, del, expressHandler, expressMiddleware, flag, get, getCacheMetrics as getSchemaCacheMetrics, hash, helmet, log, logCacheMetrics as logSchemaCacheMetrics, logger, memoryQueue, methodOverride, middleware, mountExpressRouter, mqtt, patch, pgbossQueue, post, put, rateLimiter, router, serialize, serveStatic, session, setCronGlobalErrorHandler, setMqttGlobalErrorHandler, sqsQueue, timeout as timeoutMw, trustProxy, validate };
package/lib/index.d.ts CHANGED
@@ -1453,6 +1453,7 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
1453
1453
  mountExpressRouter(basePath: string, expressRouter: Router$1): void;
1454
1454
  setErrorHandler(errorHandler?: ServerErrorHandler): void;
1455
1455
  setNotFoundHandler(notFoundHandler?: ServerRouteHandler): void;
1456
+ beforeStart(hook: ServerHook): void;
1456
1457
  listen(cb?: ServerListenCallback): void;
1457
1458
  waitUntilListening(): Promise<void>;
1458
1459
  /**
@@ -2269,6 +2270,18 @@ interface ServerInterface {
2269
2270
  * });
2270
2271
  */
2271
2272
  setNotFoundHandler: (notFoundHandler?: ServerRouteHandler) => void;
2273
+ /**
2274
+ * Register a hook to be called after bootstrap (controllers imported, plugins applied) but before the server starts accepting requests.
2275
+ * Multiple hooks are called in the order they are registered.
2276
+ * @param hook - The hook function to call, can be sync or async
2277
+ * @example
2278
+ * ```ts
2279
+ * server.beforeStart(async () => {
2280
+ * await connectToDatabase();
2281
+ * });
2282
+ * ```
2283
+ */
2284
+ beforeStart: (hook: ServerHook) => void;
2272
2285
  /**
2273
2286
  * Binds the server to the port and hostname defined in the serverOptions, meant to be called only once
2274
2287
  * It initializes the server without blocking the event loop, you can pass a callback to be called when the server is listening
@@ -2332,6 +2345,7 @@ type StandardMethodOptions = {
2332
2345
  all?: RequestSchema;
2333
2346
  swagger?: SwaggerRouteOptions;
2334
2347
  };
2348
+ type ServerHook = () => SyncOrAsync;
2335
2349
  type SignalEvent = Deno.Signal | NodeJS.Signals;
2336
2350
  type ControllerHandler<TPath extends string = string> = (req: Request<ExtractParams<TPath>>, res: Response$1, ...args: any[]) => ServerHandlerReturnType;
2337
2351
 
@@ -3191,6 +3205,8 @@ declare class CommandRegistry {
3191
3205
  private constructor();
3192
3206
  static getInstance(): CommandRegistry;
3193
3207
  static setCommandsPattern(pattern: string): void;
3208
+ getLogger(): Logger<string, boolean>;
3209
+ setLogger(logger: Logger): void;
3194
3210
  getCommand(name: string): typeof Command | null;
3195
3211
  getCommands(): (typeof Command)[];
3196
3212
  getBuiltInCommands(): (typeof Command)[];
@@ -4058,4 +4074,4 @@ declare const createPolicyDecorator: <T extends Record<string, PolicyProvider>>(
4058
4074
  */
4059
4075
  declare const router: ClientRouter;
4060
4076
 
4061
- export { type AsyncLocalStorageContextSetters, AzureBlobStorageProvider, BaseCron, BasePlugin, type BaseStorageProviderOptions, type BlobStorageProviderOptions, BullMQConfiguration, type BullMQConfigurationOptions, BullMQPubSub, Command, type CommandOptions, CommandRegistry, type CompressionOptions, type CookieMiddlewareOptions, type CorsOptions, type CronSchedule, type CronScheduleParams, CronService, type CronUIOptions, CustomAdapter, type CustomQueueConfiguration, type CustomStorageProviderOptions, CustomTypedQueue, type CustomValidationError, EdgeAdapter, EjsAdapter, type ExtractParams, GraphQL, type GraphQLContext, type GraphQLOptions, type GraphQLResolverFunction, type GraphQLResolverMap, type GraphQLResolverType, type GraphQLResolvers, type GraphQLSchemaInput, type GraphQLTypeDef, HandlebarsAdapter, type HelmetOptions, type HttpMethod, type HttpsOptions, type InferSchemaType, LocalStorageProvider, type LocalStorageProviderOptions, type LogOptions, type LoggerOptions, type MailOptions, MailOptionsBuilder, MailProvider, type MailProviderInterface, Mailer, type MailerInterface, type MailerOptions, type MailerProviderOptions, MemoryPubSub, type MethodOverrideOptions, MockResponse, MockServer, type MockServerOptions, type MqttConnectionOptions, type MqttHandler, type MqttPublishOptions, MqttService, type MqttSubscribeOptions, type MqttSubscription, type MqttTopics, MustacheAdapter, type NextFunction, type NodeHttpClient, type NodeServer as NodeHttpServerClient, PGBossConfiguration, type PGBossConfigurationOptions, PGBossPubSub, type PolicyDecorator, PolicyManager, type PolicyProvider, type PublishTopic, QueueManager, QueueService, type RateLimiterKeyOptions, Request, type RequestSchema, Response$1 as Response, type RuntimeServer, S3StorageProvider, type S3StorageProviderOptions, SQSConfiguration, type SQSConfigurationOptions, SQSPubSub, type CacheMetrics as SchemaCacheMetrics, type SerializeOptions, Server, type ServerConnectInput, type ServerErrorHandler, type ServerInterface, type ServerListenCallback, type ServerOptions, type ServerRouteHandler, type ServerRouteMiddleware, type ServerTapOptions, type SessionOptions, type SignalEvent, type StaticPluginOptions, Storage, type StorageInterface, type StorageOptions, type StorageProviderOptions, type TemplateMailOptions, type TimeoutOptions, type TrustProxyOptions, type TypedHandler, TypedQueue, type TypedRouteMetadata, type ValidatedData, type ValidationOptions, arg, asyncLocalStorage, asyncStorage, bullmqQueue, clearAllCaches as clearAllSchemaCaches, commandRegistry, compression, controller, cookie, cors, createExpressAdapter, createPolicyDecorator, createQueue, cron, Server as default, defineQueueConfiguration, del, expressHandler, expressMiddleware, flag, get, getCacheMetrics as getSchemaCacheMetrics, hash, helmet, log, logCacheMetrics as logSchemaCacheMetrics, logger, memoryQueue, methodOverride, middleware, mountExpressRouter, mqtt, patch, pgbossQueue, post, put, rateLimiter, router, serialize, serveStatic, session, setCronGlobalErrorHandler, setMqttGlobalErrorHandler, sqsQueue, timeout as timeoutMw, trustProxy, validate };
4077
+ export { type AsyncLocalStorageContextSetters, AzureBlobStorageProvider, BaseCron, BasePlugin, type BaseStorageProviderOptions, type BlobStorageProviderOptions, BullMQConfiguration, type BullMQConfigurationOptions, BullMQPubSub, Command, type CommandOptions, CommandRegistry, type CompressionOptions, type CookieMiddlewareOptions, type CorsOptions, type CronSchedule, type CronScheduleParams, CronService, type CronUIOptions, CustomAdapter, type CustomQueueConfiguration, type CustomStorageProviderOptions, CustomTypedQueue, type CustomValidationError, EdgeAdapter, EjsAdapter, type ExtractParams, GraphQL, type GraphQLContext, type GraphQLOptions, type GraphQLResolverFunction, type GraphQLResolverMap, type GraphQLResolverType, type GraphQLResolvers, type GraphQLSchemaInput, type GraphQLTypeDef, HandlebarsAdapter, type HelmetOptions, type HttpMethod, type HttpsOptions, type InferSchemaType, LocalStorageProvider, type LocalStorageProviderOptions, type LogOptions, type LoggerOptions, type MailOptions, MailOptionsBuilder, MailProvider, type MailProviderInterface, Mailer, type MailerInterface, type MailerOptions, type MailerProviderOptions, MemoryPubSub, type MethodOverrideOptions, MockResponse, MockServer, type MockServerOptions, type MqttConnectionOptions, type MqttHandler, type MqttPublishOptions, MqttService, type MqttSubscribeOptions, type MqttSubscription, type MqttTopics, MustacheAdapter, type NextFunction, type NodeHttpClient, type NodeServer as NodeHttpServerClient, PGBossConfiguration, type PGBossConfigurationOptions, PGBossPubSub, type PolicyDecorator, PolicyManager, type PolicyProvider, type PublishTopic, QueueManager, QueueService, type RateLimiterKeyOptions, Request, type RequestSchema, Response$1 as Response, type RuntimeServer, S3StorageProvider, type S3StorageProviderOptions, SQSConfiguration, type SQSConfigurationOptions, SQSPubSub, type CacheMetrics as SchemaCacheMetrics, type SerializeOptions, Server, type ServerConnectInput, type ServerErrorHandler, type ServerHook, type ServerInterface, type ServerListenCallback, type ServerOptions, type ServerRouteHandler, type ServerRouteMiddleware, type ServerTapOptions, type SessionOptions, type SignalEvent, type StaticPluginOptions, Storage, type StorageInterface, type StorageOptions, type StorageProviderOptions, type TemplateMailOptions, type TimeoutOptions, type TrustProxyOptions, type TypedHandler, TypedQueue, type TypedRouteMetadata, type ValidatedData, type ValidationOptions, arg, asyncLocalStorage, asyncStorage, bullmqQueue, clearAllCaches as clearAllSchemaCaches, commandRegistry, compression, controller, cookie, cors, createExpressAdapter, createPolicyDecorator, createQueue, cron, Server as default, defineQueueConfiguration, del, expressHandler, expressMiddleware, flag, get, getCacheMetrics as getSchemaCacheMetrics, hash, helmet, log, logCacheMetrics as logSchemaCacheMetrics, logger, memoryQueue, methodOverride, middleware, mountExpressRouter, mqtt, patch, pgbossQueue, post, put, rateLimiter, router, serialize, serveStatic, session, setCronGlobalErrorHandler, setMqttGlobalErrorHandler, sqsQueue, timeout as timeoutMw, trustProxy, validate };