balda 0.0.4 → 0.0.6

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
@@ -13,9 +13,9 @@ import * as pino from 'pino';
13
13
  import pino__default, { pino as pino$1 } from 'pino';
14
14
  import { TSchema } from '@sinclair/typebox';
15
15
  import { IClientSubscribeOptions, IClientOptions, IClientPublishOptions, MqttClient } from 'mqtt';
16
- import { SQSClientConfig, SQSClient } from '@aws-sdk/client-sqs';
17
- import { Queue, Job } from 'bullmq';
18
- import { PgBoss } from 'pg-boss';
16
+ import { SQSClientConfig, SendMessageCommandInput } from '@aws-sdk/client-sqs';
17
+ import { Queue, JobsOptions, Job } from 'bullmq';
18
+ import { SendOptions } from 'pg-boss';
19
19
  import { AsyncLocalStorage } from 'node:async_hooks';
20
20
  import { S3Client } from '@aws-sdk/client-s3';
21
21
 
@@ -1163,25 +1163,16 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
1163
1163
  expressMiddleware(middleware: RequestHandler): ServerRouteMiddleware;
1164
1164
  mountExpressRouter(basePath: string, expressRouter: Router$1): void;
1165
1165
  setErrorHandler(errorHandler?: ServerErrorHandler): void;
1166
- /**
1167
- * Sets a custom handler for 404 Not Found responses.
1168
- * If not set, the default RouteNotFoundError will be used.
1169
- *
1170
- * @param notFoundHandler - Optional handler to customize 404 responses
1171
- * @example
1172
- * server.setNotFoundHandler((req, res) => {
1173
- * res.status(404).json({ error: "Custom not found message" });
1174
- * });
1175
- */
1176
1166
  setNotFoundHandler(notFoundHandler?: ServerRouteHandler): void;
1177
1167
  listen(cb?: ServerListenCallback): void;
1168
+ waitUntilListening(): Promise<void>;
1178
1169
  close(): Promise<void>;
1179
- /**
1180
- * Returns a mock server instance that can be used to test the server without starting it
1181
- * It will import the controllers and apply the plugins to the mock server
1182
- * @param options - The options for the mock server
1183
- * @param options.controllerPatterns - Custom controller patterns to import if the mock server must not be initialized with the same controller patterns as the server
1184
- */
1170
+ disconnect(): Promise<void>;
1171
+ configureHash(options: {
1172
+ iterations?: number;
1173
+ saltLength?: number;
1174
+ keyLength?: number;
1175
+ }): void;
1185
1176
  getMockServer(options?: Pick<ServerOptions, "controllerPatterns">): Promise<MockServer>;
1186
1177
  private importControllers;
1187
1178
  private extractOptionsAndHandlerFromRouteRegistration;
@@ -1847,21 +1838,55 @@ interface ServerInterface {
1847
1838
  */
1848
1839
  setErrorHandler: (errorHandler?: ServerErrorHandler) => void;
1849
1840
  /**
1850
- * Set the not found handler for the server
1851
- * @param notFoundHandler - The not found handler to be applied to all routes
1841
+ * Sets a custom handler for 404 Not Found responses.
1842
+ * If not set, the default RouteNotFoundError will be used.
1843
+ *
1844
+ * @param notFoundHandler - Optional handler to customize 404 responses
1845
+ * @example
1846
+ * server.setNotFoundHandler((req, res) => {
1847
+ * res.status(404).json({ error: "Custom not found message" });
1848
+ * });
1852
1849
  */
1853
1850
  setNotFoundHandler: (notFoundHandler?: ServerRouteHandler) => void;
1854
1851
  /**
1855
1852
  * Binds the server to the port and hostname defined in the serverOptions, meant to be called only once
1853
+ * It initializes the server without blocking the event loop, you can pass a callback to be called when the server is listening
1854
+ * Use `waitUntilListening` instead if you want to wait for the server to be listening for requests before returning
1856
1855
  * @warning All routes defined with decorators are defined on this method just before the server starts listening for requests
1857
1856
  */
1858
1857
  listen: (cb?: ServerListenCallback) => void;
1859
1858
  /**
1860
- * Closes the server and frees the port
1859
+ * Binds the server to the port and hostname defined in the serverOptions, meant to be called only once
1860
+ * It initializes the server blocking the event loop, it will wait for the server to be listening for requests before returning
1861
+ * Use `listen` instead if you want to initialize the server without blocking the event loop
1862
+ * @warning All routes defined with decorators are defined on this method just before the server starts listening for requests
1863
+ */
1864
+ waitUntilListening: () => Promise<void>;
1865
+ /**
1866
+ * @alias disconnect
1861
1867
  */
1862
1868
  close: () => Promise<void>;
1863
1869
  /**
1864
- * Get a mock server instance, useful for testing purposes
1870
+ * Closes the server and frees the port
1871
+ */
1872
+ disconnect: () => Promise<void>;
1873
+ /**
1874
+ * Configure hash settings for password hashing
1875
+ * @param options - Hash configuration options
1876
+ * @param options.iterations - Number of PBKDF2 iterations (default: 600,000)
1877
+ * @param options.saltLength - Salt length in bytes (default: 16)
1878
+ * @param options.keyLength - Key length in bits (default: 256)
1879
+ */
1880
+ configureHash: (options: {
1881
+ iterations?: number;
1882
+ saltLength?: number;
1883
+ keyLength?: number;
1884
+ }) => void;
1885
+ /**
1886
+ * Returns a mock server instance that can be used to test the server without starting it
1887
+ * It will import the controllers and apply the plugins to the mock server
1888
+ * @param options - The options for the mock server
1889
+ * @param options.controllerPatterns - Custom controller patterns to import if the mock server must not be initialized with the same controller patterns as the server
1865
1890
  */
1866
1891
  getMockServer: () => Promise<MockServer>;
1867
1892
  /**
@@ -2220,9 +2245,9 @@ declare class SQSPubSub implements GenericPubSub {
2220
2245
  private getClientWithConfig;
2221
2246
  }
2222
2247
 
2223
- type BullMQAddTaskOptions = Parameters<Queue["add"]>[2];
2224
- type PGBossSendOptions = Parameters<PgBoss["send"]>[2];
2225
- type SQSPublishOptions = Parameters<SQSClient["send"]>[0];
2248
+ type BullMQAddTaskOptions = JobsOptions;
2249
+ type PGBossSendOptions = SendOptions;
2250
+ type SQSPublishOptions = Omit<SendMessageCommandInput, "MessageBody">;
2226
2251
  type BuiltInProviderKey = "bullmq" | "sqs" | "pgboss";
2227
2252
  type PublishOptions<T extends BuiltInProviderKey> = T extends "bullmq" ? BullMQAddTaskOptions : T extends "sqs" ? SQSPublishOptions : T extends "pgboss" ? PGBossSendOptions : never;
2228
2253
  type SQSQueueOptions = {
@@ -2821,9 +2846,14 @@ declare class CommandRegistry {
2821
2846
  declare const commandRegistry: CommandRegistry;
2822
2847
 
2823
2848
  declare class NativeHash {
2824
- private readonly ITERATIONS;
2825
- private readonly SALT_LENGTH;
2826
- private readonly KEY_LENGTH;
2849
+ private ITERATIONS;
2850
+ private SALT_LENGTH;
2851
+ private KEY_LENGTH;
2852
+ configure(options: {
2853
+ iterations?: number;
2854
+ saltLength?: number;
2855
+ keyLength?: number;
2856
+ }): void;
2827
2857
  hash(data: string): Promise<string>;
2828
2858
  compare(hash: string, data: string): Promise<boolean>;
2829
2859
  private encodeBase64;
package/lib/index.d.ts CHANGED
@@ -13,9 +13,9 @@ import * as pino from 'pino';
13
13
  import pino__default, { pino as pino$1 } from 'pino';
14
14
  import { TSchema } from '@sinclair/typebox';
15
15
  import { IClientSubscribeOptions, IClientOptions, IClientPublishOptions, MqttClient } from 'mqtt';
16
- import { SQSClientConfig, SQSClient } from '@aws-sdk/client-sqs';
17
- import { Queue, Job } from 'bullmq';
18
- import { PgBoss } from 'pg-boss';
16
+ import { SQSClientConfig, SendMessageCommandInput } from '@aws-sdk/client-sqs';
17
+ import { Queue, JobsOptions, Job } from 'bullmq';
18
+ import { SendOptions } from 'pg-boss';
19
19
  import { AsyncLocalStorage } from 'node:async_hooks';
20
20
  import { S3Client } from '@aws-sdk/client-s3';
21
21
 
@@ -1163,25 +1163,16 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
1163
1163
  expressMiddleware(middleware: RequestHandler): ServerRouteMiddleware;
1164
1164
  mountExpressRouter(basePath: string, expressRouter: Router$1): void;
1165
1165
  setErrorHandler(errorHandler?: ServerErrorHandler): void;
1166
- /**
1167
- * Sets a custom handler for 404 Not Found responses.
1168
- * If not set, the default RouteNotFoundError will be used.
1169
- *
1170
- * @param notFoundHandler - Optional handler to customize 404 responses
1171
- * @example
1172
- * server.setNotFoundHandler((req, res) => {
1173
- * res.status(404).json({ error: "Custom not found message" });
1174
- * });
1175
- */
1176
1166
  setNotFoundHandler(notFoundHandler?: ServerRouteHandler): void;
1177
1167
  listen(cb?: ServerListenCallback): void;
1168
+ waitUntilListening(): Promise<void>;
1178
1169
  close(): Promise<void>;
1179
- /**
1180
- * Returns a mock server instance that can be used to test the server without starting it
1181
- * It will import the controllers and apply the plugins to the mock server
1182
- * @param options - The options for the mock server
1183
- * @param options.controllerPatterns - Custom controller patterns to import if the mock server must not be initialized with the same controller patterns as the server
1184
- */
1170
+ disconnect(): Promise<void>;
1171
+ configureHash(options: {
1172
+ iterations?: number;
1173
+ saltLength?: number;
1174
+ keyLength?: number;
1175
+ }): void;
1185
1176
  getMockServer(options?: Pick<ServerOptions, "controllerPatterns">): Promise<MockServer>;
1186
1177
  private importControllers;
1187
1178
  private extractOptionsAndHandlerFromRouteRegistration;
@@ -1847,21 +1838,55 @@ interface ServerInterface {
1847
1838
  */
1848
1839
  setErrorHandler: (errorHandler?: ServerErrorHandler) => void;
1849
1840
  /**
1850
- * Set the not found handler for the server
1851
- * @param notFoundHandler - The not found handler to be applied to all routes
1841
+ * Sets a custom handler for 404 Not Found responses.
1842
+ * If not set, the default RouteNotFoundError will be used.
1843
+ *
1844
+ * @param notFoundHandler - Optional handler to customize 404 responses
1845
+ * @example
1846
+ * server.setNotFoundHandler((req, res) => {
1847
+ * res.status(404).json({ error: "Custom not found message" });
1848
+ * });
1852
1849
  */
1853
1850
  setNotFoundHandler: (notFoundHandler?: ServerRouteHandler) => void;
1854
1851
  /**
1855
1852
  * Binds the server to the port and hostname defined in the serverOptions, meant to be called only once
1853
+ * It initializes the server without blocking the event loop, you can pass a callback to be called when the server is listening
1854
+ * Use `waitUntilListening` instead if you want to wait for the server to be listening for requests before returning
1856
1855
  * @warning All routes defined with decorators are defined on this method just before the server starts listening for requests
1857
1856
  */
1858
1857
  listen: (cb?: ServerListenCallback) => void;
1859
1858
  /**
1860
- * Closes the server and frees the port
1859
+ * Binds the server to the port and hostname defined in the serverOptions, meant to be called only once
1860
+ * It initializes the server blocking the event loop, it will wait for the server to be listening for requests before returning
1861
+ * Use `listen` instead if you want to initialize the server without blocking the event loop
1862
+ * @warning All routes defined with decorators are defined on this method just before the server starts listening for requests
1863
+ */
1864
+ waitUntilListening: () => Promise<void>;
1865
+ /**
1866
+ * @alias disconnect
1861
1867
  */
1862
1868
  close: () => Promise<void>;
1863
1869
  /**
1864
- * Get a mock server instance, useful for testing purposes
1870
+ * Closes the server and frees the port
1871
+ */
1872
+ disconnect: () => Promise<void>;
1873
+ /**
1874
+ * Configure hash settings for password hashing
1875
+ * @param options - Hash configuration options
1876
+ * @param options.iterations - Number of PBKDF2 iterations (default: 600,000)
1877
+ * @param options.saltLength - Salt length in bytes (default: 16)
1878
+ * @param options.keyLength - Key length in bits (default: 256)
1879
+ */
1880
+ configureHash: (options: {
1881
+ iterations?: number;
1882
+ saltLength?: number;
1883
+ keyLength?: number;
1884
+ }) => void;
1885
+ /**
1886
+ * Returns a mock server instance that can be used to test the server without starting it
1887
+ * It will import the controllers and apply the plugins to the mock server
1888
+ * @param options - The options for the mock server
1889
+ * @param options.controllerPatterns - Custom controller patterns to import if the mock server must not be initialized with the same controller patterns as the server
1865
1890
  */
1866
1891
  getMockServer: () => Promise<MockServer>;
1867
1892
  /**
@@ -2220,9 +2245,9 @@ declare class SQSPubSub implements GenericPubSub {
2220
2245
  private getClientWithConfig;
2221
2246
  }
2222
2247
 
2223
- type BullMQAddTaskOptions = Parameters<Queue["add"]>[2];
2224
- type PGBossSendOptions = Parameters<PgBoss["send"]>[2];
2225
- type SQSPublishOptions = Parameters<SQSClient["send"]>[0];
2248
+ type BullMQAddTaskOptions = JobsOptions;
2249
+ type PGBossSendOptions = SendOptions;
2250
+ type SQSPublishOptions = Omit<SendMessageCommandInput, "MessageBody">;
2226
2251
  type BuiltInProviderKey = "bullmq" | "sqs" | "pgboss";
2227
2252
  type PublishOptions<T extends BuiltInProviderKey> = T extends "bullmq" ? BullMQAddTaskOptions : T extends "sqs" ? SQSPublishOptions : T extends "pgboss" ? PGBossSendOptions : never;
2228
2253
  type SQSQueueOptions = {
@@ -2821,9 +2846,14 @@ declare class CommandRegistry {
2821
2846
  declare const commandRegistry: CommandRegistry;
2822
2847
 
2823
2848
  declare class NativeHash {
2824
- private readonly ITERATIONS;
2825
- private readonly SALT_LENGTH;
2826
- private readonly KEY_LENGTH;
2849
+ private ITERATIONS;
2850
+ private SALT_LENGTH;
2851
+ private KEY_LENGTH;
2852
+ configure(options: {
2853
+ iterations?: number;
2854
+ saltLength?: number;
2855
+ keyLength?: number;
2856
+ }): void;
2827
2857
  hash(data: string): Promise<string>;
2828
2858
  compare(hash: string, data: string): Promise<boolean>;
2829
2859
  private encodeBase64;