@onebun/core 0.1.2 → 0.1.4

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 (79) hide show
  1. package/package.json +6 -6
  2. package/src/{application.test.ts → application/application.test.ts} +6 -5
  3. package/src/{application.ts → application/application.ts} +131 -12
  4. package/src/application/index.ts +9 -0
  5. package/src/{multi-service-application.test.ts → application/multi-service-application.test.ts} +2 -1
  6. package/src/{multi-service-application.ts → application/multi-service-application.ts} +2 -1
  7. package/src/{multi-service.types.ts → application/multi-service.types.ts} +1 -1
  8. package/src/{decorators.test.ts → decorators/decorators.test.ts} +2 -1
  9. package/src/{decorators.ts → decorators/decorators.ts} +3 -2
  10. package/src/decorators/index.ts +15 -0
  11. package/src/index.ts +47 -134
  12. package/src/module/index.ts +12 -0
  13. package/src/{module.test.ts → module/module.test.ts} +3 -2
  14. package/src/{module.ts → module/module.ts} +6 -5
  15. package/src/queue/adapters/index.ts +8 -0
  16. package/src/queue/adapters/memory.adapter.test.ts +405 -0
  17. package/src/queue/adapters/memory.adapter.ts +509 -0
  18. package/src/queue/adapters/redis.adapter.ts +673 -0
  19. package/src/queue/cron-expression.test.ts +145 -0
  20. package/src/queue/cron-expression.ts +115 -0
  21. package/src/queue/cron-parser.test.ts +185 -0
  22. package/src/queue/cron-parser.ts +287 -0
  23. package/src/queue/decorators.test.ts +292 -0
  24. package/src/queue/decorators.ts +493 -0
  25. package/src/queue/docs-examples.test.ts +449 -0
  26. package/src/queue/guards.test.ts +309 -0
  27. package/src/queue/guards.ts +307 -0
  28. package/src/queue/index.ts +118 -0
  29. package/src/queue/pattern-matcher.test.ts +191 -0
  30. package/src/queue/pattern-matcher.ts +252 -0
  31. package/src/queue/queue.service.ts +421 -0
  32. package/src/queue/scheduler.test.ts +235 -0
  33. package/src/queue/scheduler.ts +379 -0
  34. package/src/queue/types.ts +502 -0
  35. package/src/redis/index.ts +8 -0
  36. package/src/{env-resolver.ts → service-client/env-resolver.ts} +1 -1
  37. package/src/service-client/index.ts +10 -0
  38. package/src/{service-client.test.ts → service-client/service-client.test.ts} +3 -2
  39. package/src/{service-client.ts → service-client/service-client.ts} +1 -1
  40. package/src/{service-definition.test.ts → service-client/service-definition.test.ts} +3 -2
  41. package/src/{service-definition.ts → service-client/service-definition.ts} +2 -2
  42. package/src/testing/index.ts +7 -0
  43. package/src/types.ts +34 -5
  44. package/src/websocket/index.ts +50 -0
  45. package/src/{ws-decorators.ts → websocket/ws-decorators.ts} +2 -1
  46. package/src/{ws-integration.test.ts → websocket/ws-integration.test.ts} +3 -2
  47. package/src/{ws-service-definition.ts → websocket/ws-service-definition.ts} +2 -1
  48. package/src/{ws-storage-redis.ts → websocket/ws-storage-redis.ts} +1 -1
  49. /package/src/{metadata.test.ts → decorators/metadata.test.ts} +0 -0
  50. /package/src/{metadata.ts → decorators/metadata.ts} +0 -0
  51. /package/src/{config.service.test.ts → module/config.service.test.ts} +0 -0
  52. /package/src/{config.service.ts → module/config.service.ts} +0 -0
  53. /package/src/{controller.test.ts → module/controller.test.ts} +0 -0
  54. /package/src/{controller.ts → module/controller.ts} +0 -0
  55. /package/src/{service.test.ts → module/service.test.ts} +0 -0
  56. /package/src/{service.ts → module/service.ts} +0 -0
  57. /package/src/{redis-client.ts → redis/redis-client.ts} +0 -0
  58. /package/src/{shared-redis.ts → redis/shared-redis.ts} +0 -0
  59. /package/src/{env-resolver.test.ts → service-client/env-resolver.test.ts} +0 -0
  60. /package/src/{service-client.types.ts → service-client/service-client.types.ts} +0 -0
  61. /package/src/{test-utils.test.ts → testing/test-utils.test.ts} +0 -0
  62. /package/src/{test-utils.ts → testing/test-utils.ts} +0 -0
  63. /package/src/{ws-base-gateway.test.ts → websocket/ws-base-gateway.test.ts} +0 -0
  64. /package/src/{ws-base-gateway.ts → websocket/ws-base-gateway.ts} +0 -0
  65. /package/src/{ws-client.test.ts → websocket/ws-client.test.ts} +0 -0
  66. /package/src/{ws-client.ts → websocket/ws-client.ts} +0 -0
  67. /package/src/{ws-client.types.ts → websocket/ws-client.types.ts} +0 -0
  68. /package/src/{ws-decorators.test.ts → websocket/ws-decorators.test.ts} +0 -0
  69. /package/src/{ws-guards.test.ts → websocket/ws-guards.test.ts} +0 -0
  70. /package/src/{ws-guards.ts → websocket/ws-guards.ts} +0 -0
  71. /package/src/{ws-handler.ts → websocket/ws-handler.ts} +0 -0
  72. /package/src/{ws-pattern-matcher.test.ts → websocket/ws-pattern-matcher.test.ts} +0 -0
  73. /package/src/{ws-pattern-matcher.ts → websocket/ws-pattern-matcher.ts} +0 -0
  74. /package/src/{ws-socketio-protocol.test.ts → websocket/ws-socketio-protocol.test.ts} +0 -0
  75. /package/src/{ws-socketio-protocol.ts → websocket/ws-socketio-protocol.ts} +0 -0
  76. /package/src/{ws-storage-memory.test.ts → websocket/ws-storage-memory.test.ts} +0 -0
  77. /package/src/{ws-storage-memory.ts → websocket/ws-storage-memory.ts} +0 -0
  78. /package/src/{ws-storage.ts → websocket/ws-storage.ts} +0 -0
  79. /package/src/{ws.types.ts → websocket/ws.types.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onebun/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Core package for OneBun framework - decorators, DI, modules, controllers",
5
5
  "license": "LGPL-3.0",
6
6
  "author": "RemRyahirev",
@@ -41,11 +41,11 @@
41
41
  "dependencies": {
42
42
  "effect": "^3.13.10",
43
43
  "arktype": "^2.0.0",
44
- "@onebun/logger": "^0.1.0",
45
- "@onebun/envs": "^0.1.0",
46
- "@onebun/metrics": "^0.1.0",
47
- "@onebun/requests": "^0.1.0",
48
- "@onebun/trace": "^0.1.0"
44
+ "@onebun/logger": "workspace:^",
45
+ "@onebun/envs": "workspace:^",
46
+ "@onebun/metrics": "workspace:^",
47
+ "@onebun/requests": "workspace:^",
48
+ "@onebun/trace": "workspace:^"
49
49
  },
50
50
  "devDependencies": {
51
51
  "bun-types": "1.2.2"
@@ -9,10 +9,8 @@ import {
9
9
  // eslint-disable-next-line import/no-extraneous-dependencies
10
10
  import { register } from 'prom-client';
11
11
 
12
- import type { ApplicationOptions } from './types';
12
+ import type { ApplicationOptions } from '../types';
13
13
 
14
- import { OneBunApplication } from './application';
15
- import { Controller as BaseController } from './controller';
16
14
  import {
17
15
  Module,
18
16
  Controller,
@@ -21,8 +19,11 @@ import {
21
19
  Param,
22
20
  Query,
23
21
  Body,
24
- } from './decorators';
25
- import { makeMockLoggerLayer } from './test-utils';
22
+ } from '../decorators/decorators';
23
+ import { Controller as BaseController } from '../module/controller';
24
+ import { makeMockLoggerLayer } from '../testing/test-utils';
25
+
26
+ import { OneBunApplication } from './application';
26
27
 
27
28
  // Helper function to create app with mock logger to suppress logs in tests
28
29
  function createTestApp(
@@ -1,7 +1,7 @@
1
1
  import { Effect, type Layer } from 'effect';
2
2
 
3
- import type { Controller } from './controller';
4
- import type { WsClientData } from './ws.types';
3
+ import type { Controller } from '../module/controller';
4
+ import type { WsClientData } from '../websocket/ws.types';
5
5
 
6
6
  import { TypedEnv } from '@onebun/envs';
7
7
  import {
@@ -20,20 +20,24 @@ import {
20
20
  } from '@onebun/requests';
21
21
  import { makeTraceService, TraceService } from '@onebun/trace';
22
22
 
23
- import { ConfigServiceImpl } from './config.service';
24
- import { getControllerMetadata } from './decorators';
25
- import { OneBunModule } from './module';
26
- import { SharedRedisProvider } from './shared-redis';
23
+ import { getControllerMetadata } from '../decorators/decorators';
24
+ import { ConfigServiceImpl } from '../module/config.service';
25
+ import { OneBunModule } from '../module/module';
26
+ import { QueueService, type QueueAdapter } from '../queue';
27
+ import { InMemoryQueueAdapter } from '../queue/adapters/memory.adapter';
28
+ import { RedisQueueAdapter } from '../queue/adapters/redis.adapter';
29
+ import { hasQueueDecorators } from '../queue/decorators';
30
+ import { SharedRedisProvider } from '../redis/shared-redis';
27
31
  import {
28
32
  type ApplicationOptions,
29
33
  type HttpMethod,
30
- type Module,
34
+ type ModuleInstance,
31
35
  type ParamMetadata,
32
36
  ParamType,
33
37
  type RouteMetadata,
34
- } from './types';
35
- import { validateOrThrow } from './validation';
36
- import { WsHandler, isWebSocketGateway } from './ws-handler';
38
+ } from '../types';
39
+ import { validateOrThrow } from '../validation';
40
+ import { WsHandler, isWebSocketGateway } from '../websocket/ws-handler';
37
41
 
38
42
  // Conditionally import metrics
39
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -63,7 +67,7 @@ function clearGlobalTraceContext(): void {
63
67
  * OneBun Application
64
68
  */
65
69
  export class OneBunApplication {
66
- private rootModule: Module;
70
+ private rootModule: ModuleInstance;
67
71
  private server: ReturnType<typeof Bun.serve> | null = null;
68
72
  private options: ApplicationOptions = {
69
73
  port: 3000,
@@ -79,6 +83,8 @@ export class OneBunApplication {
79
83
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
84
  private traceService: any = null;
81
85
  private wsHandler: WsHandler | null = null;
86
+ private queueService: QueueService | null = null;
87
+ private queueAdapter: QueueAdapter | null = null;
82
88
 
83
89
  /**
84
90
  * Create application instance
@@ -272,12 +278,15 @@ export class OneBunApplication {
272
278
  if (isWebSocketGateway(controllerClass)) {
273
279
  const instance = this.rootModule.getControllerInstance?.(controllerClass);
274
280
  if (instance) {
275
- this.wsHandler.registerGateway(controllerClass, instance as import('./ws-base-gateway').BaseWebSocketGateway);
281
+ this.wsHandler.registerGateway(controllerClass, instance as import('../websocket/ws-base-gateway').BaseWebSocketGateway);
276
282
  this.logger.info(`Registered WebSocket gateway: ${controllerClass.name}`);
277
283
  }
278
284
  }
279
285
  }
280
286
 
287
+ // Initialize Queue system if configured or handlers exist
288
+ await this.initializeQueue(controllers);
289
+
281
290
  // Create a map of routes with metadata
282
291
  const routes = new Map<
283
292
  string,
@@ -987,6 +996,20 @@ export class OneBunApplication {
987
996
  this.wsHandler = null;
988
997
  }
989
998
 
999
+ // Stop queue service
1000
+ if (this.queueService) {
1001
+ this.logger.debug('Stopping queue service');
1002
+ await this.queueService.stop();
1003
+ this.queueService = null;
1004
+ }
1005
+
1006
+ // Disconnect queue adapter
1007
+ if (this.queueAdapter) {
1008
+ this.logger.debug('Disconnecting queue adapter');
1009
+ await this.queueAdapter.disconnect();
1010
+ this.queueAdapter = null;
1011
+ }
1012
+
990
1013
  // Stop HTTP server
991
1014
  if (this.server) {
992
1015
  this.server.stop();
@@ -1003,6 +1026,102 @@ export class OneBunApplication {
1003
1026
  this.logger.info('OneBun application stopped');
1004
1027
  }
1005
1028
 
1029
+ /**
1030
+ * Initialize the queue system based on configuration and detected handlers
1031
+ */
1032
+ private async initializeQueue(controllers: Function[]): Promise<void> {
1033
+ const queueOptions = this.options.queue;
1034
+
1035
+ // Check if any controller has queue-related decorators
1036
+ const hasQueueHandlers = controllers.some(controller => {
1037
+ const instance = this.rootModule.getControllerInstance?.(controller);
1038
+ if (!instance) {
1039
+ return false;
1040
+ }
1041
+
1042
+ return hasQueueDecorators(instance.constructor);
1043
+ });
1044
+
1045
+ // Determine if queue should be enabled
1046
+ const shouldEnableQueue = queueOptions?.enabled ?? hasQueueHandlers;
1047
+ if (!shouldEnableQueue) {
1048
+ this.logger.debug('Queue system not enabled (no handlers detected or explicitly disabled)');
1049
+
1050
+ return;
1051
+ }
1052
+
1053
+ // Create the appropriate adapter
1054
+ const adapterType = queueOptions?.adapter ?? 'memory';
1055
+
1056
+ if (adapterType === 'memory') {
1057
+ this.queueAdapter = new InMemoryQueueAdapter();
1058
+ this.logger.info('Queue system initialized with in-memory adapter');
1059
+ } else if (adapterType === 'redis') {
1060
+ const redisOptions = queueOptions?.redis ?? {};
1061
+ if (redisOptions.useSharedProvider !== false) {
1062
+ // Use shared Redis provider
1063
+ this.queueAdapter = new RedisQueueAdapter({
1064
+ useSharedClient: true,
1065
+ keyPrefix: redisOptions.prefix ?? 'onebun:queue:',
1066
+ });
1067
+ this.logger.info('Queue system initialized with Redis adapter (shared provider)');
1068
+ } else if (redisOptions.url) {
1069
+ // Create dedicated Redis connection
1070
+ this.queueAdapter = new RedisQueueAdapter({
1071
+ useSharedClient: false,
1072
+ url: redisOptions.url,
1073
+ keyPrefix: redisOptions.prefix ?? 'onebun:queue:',
1074
+ });
1075
+ this.logger.info('Queue system initialized with Redis adapter (dedicated connection)');
1076
+ } else {
1077
+ throw new Error('Redis queue adapter requires either useSharedProvider: true or a url');
1078
+ }
1079
+ } else {
1080
+ throw new Error(`Unknown queue adapter type: ${adapterType}`);
1081
+ }
1082
+
1083
+ // Connect the adapter
1084
+ await this.queueAdapter.connect();
1085
+
1086
+ // Create queue service with config
1087
+ this.queueService = new QueueService({
1088
+ adapter: adapterType,
1089
+ options: queueOptions?.redis,
1090
+ });
1091
+
1092
+ // Initialize with the adapter
1093
+ await this.queueService.initialize(this.queueAdapter);
1094
+
1095
+ // Register handlers from controllers using registerService
1096
+ for (const controllerClass of controllers) {
1097
+ const instance = this.rootModule.getControllerInstance?.(controllerClass);
1098
+ if (!instance) {
1099
+ continue;
1100
+ }
1101
+
1102
+ // Only register if the controller has queue decorators
1103
+ if (hasQueueDecorators(controllerClass)) {
1104
+ await this.queueService.registerService(
1105
+ instance,
1106
+ controllerClass as new (...args: unknown[]) => unknown,
1107
+ );
1108
+ this.logger.debug(`Registered queue handlers for controller: ${controllerClass.name}`);
1109
+ }
1110
+ }
1111
+
1112
+ // Start the queue service
1113
+ await this.queueService.start();
1114
+ this.logger.info('Queue service started');
1115
+ }
1116
+
1117
+ /**
1118
+ * Get the queue service instance
1119
+ * @returns The queue service or null if not enabled
1120
+ */
1121
+ getQueueService(): QueueService | null {
1122
+ return this.queueService;
1123
+ }
1124
+
1006
1125
  /**
1007
1126
  * Register signal handlers for graceful shutdown
1008
1127
  * Call this after start() to enable automatic shutdown on SIGTERM/SIGINT
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Application Module
3
+ *
4
+ * Application bootstrapping and multi-service support.
5
+ */
6
+
7
+ export * from './multi-service.types';
8
+ export * from './application';
9
+ export * from './multi-service-application';
@@ -7,7 +7,8 @@ import {
7
7
 
8
8
  import { TypedEnv } from '@onebun/envs';
9
9
 
10
- import { Module } from './decorators';
10
+ import { Module } from '../decorators/decorators';
11
+
11
12
  import { MultiServiceApplication } from './multi-service-application';
12
13
 
13
14
  // Test modules
@@ -15,8 +15,9 @@ import {
15
15
  type SyncLogger,
16
16
  } from '@onebun/logger';
17
17
 
18
+ import { resolveEnvOverrides } from '../service-client/env-resolver';
19
+
18
20
  import { OneBunApplication } from './application';
19
- import { resolveEnvOverrides } from './env-resolver';
20
21
 
21
22
  /**
22
23
  * ENV schema for service filtering
@@ -1,4 +1,4 @@
1
- import type { ApplicationOptions } from './types';
1
+ import type { ApplicationOptions } from '../types';
2
2
 
3
3
  import type { EnvLoadOptions, EnvSchema } from '@onebun/envs';
4
4
 
@@ -12,6 +12,8 @@ import {
12
12
  beforeEach,
13
13
  } from 'bun:test';
14
14
 
15
+ import { HttpMethod, ParamType } from '../types';
16
+
15
17
  import {
16
18
  injectable,
17
19
  Controller,
@@ -39,7 +41,6 @@ import {
39
41
  getModuleMetadata,
40
42
  ApiResponse,
41
43
  } from './decorators';
42
- import { HttpMethod, ParamType } from './types';
43
44
 
44
45
  describe('decorators', () => {
45
46
  beforeEach(() => {
@@ -1,13 +1,14 @@
1
1
  import './metadata'; // Import polyfill first
2
2
  import type { Type } from 'arktype';
3
3
 
4
- import { getConstructorParamTypes as getDesignParamTypes, Reflect } from './metadata';
5
4
  import {
6
5
  type ControllerMetadata,
7
6
  HttpMethod,
8
7
  type ParamMetadata,
9
8
  ParamType,
10
- } from './types';
9
+ } from '../types';
10
+
11
+ import { getConstructorParamTypes as getDesignParamTypes, Reflect } from './metadata';
11
12
 
12
13
  /**
13
14
  * Metadata storage for controllers
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Decorators Module
3
+ *
4
+ * HTTP decorators and metadata utilities.
5
+ */
6
+
7
+ // Export metadata utilities (excluding getConstructorParamTypes which is re-exported from decorators)
8
+ export {
9
+ defineMetadata,
10
+ getMetadata,
11
+ Reflect,
12
+ } from './metadata';
13
+
14
+ // Export all decorators (including getConstructorParamTypes)
15
+ export * from './decorators';
package/src/index.ts CHANGED
@@ -1,7 +1,4 @@
1
- // export * from './metadata';
2
- // export * from './types';
3
- // export * from './config.service';
4
- // Re-export envs from @onebun/envs
1
+ // Re-export from external packages
5
2
  export { Env, type EnvSchema, EnvValidationError } from '@onebun/envs';
6
3
  export type { SyncLogger } from '@onebun/logger';
7
4
  export {
@@ -15,147 +12,63 @@ export {
15
12
  type SuccessResponse,
16
13
  } from '@onebun/requests';
17
14
  export { Span } from '@onebun/trace';
15
+
18
16
  // Re-export Effect and Layer from effect
19
17
  export { Effect, Layer } from 'effect';
20
- export { OneBunApplication } from './application';
21
- export { Controller as BaseController } from './controller';
22
- export * from './decorators';
23
- export { defineMetadata, getMetadata } from './metadata';
24
- export { OneBunModule } from './module';
25
- export { BaseService, getServiceTag, Service } from './service';
26
- export {
27
- FakeTimers,
28
- fakeTimers,
29
- useFakeTimers,
30
- makeMockLoggerLayer,
31
- } from './test-utils';
18
+
19
+ // Types (excluding WebSocket types that are re-exported from ./websocket)
32
20
  export {
33
21
  HttpMethod,
34
- type RouteMetadata,
35
- type ControllerMetadata,
22
+ ParamType,
23
+ type ServiceInterface,
24
+ type ModuleProviders,
25
+ type ModuleInstance,
26
+ type TypedEnvSchema,
27
+ type ApplicationOptions,
36
28
  type ParamMetadata,
37
29
  type ResponseSchemaMetadata,
38
- ParamType,
30
+ type RouteMetadata,
31
+ type ControllerMetadata,
32
+ // WebSocket types are exported from ./websocket
33
+ type WsStorageType,
34
+ type WsStorageOptions,
35
+ type WebSocketApplicationOptions,
39
36
  } from './types';
40
- export * from './validation';
41
37
 
42
- // Multi-service application
43
- export { MultiServiceApplication } from './multi-service-application';
44
- export type {
45
- MultiServiceApplicationOptions,
46
- ServiceConfig,
47
- ServicesMap,
48
- BaseServiceOptions,
49
- EnvOverrideValue,
50
- EnvOverrides,
51
- } from './multi-service.types';
38
+ // Decorators and Metadata (exports Controller decorator, Module decorator, etc.)
39
+ export * from './decorators';
40
+
41
+ // Module System - explicitly re-export to avoid Controller conflict
42
+ export {
43
+ OneBunModule,
44
+ Controller as BaseController,
45
+ BaseService,
46
+ Service,
47
+ getServiceMetadata,
48
+ getServiceTag,
49
+ createServiceLayer,
50
+ ConfigServiceImpl,
51
+ ConfigServiceTag,
52
+ ConfigService,
53
+ } from './module';
52
54
 
53
- // Service definition and client
54
- export { createServiceDefinition } from './service-definition';
55
- export type {
56
- ServiceDefinition,
57
- EndpointMetadata,
58
- ControllerDefinition,
59
- } from './service-definition';
55
+ // Application
56
+ export * from './application';
60
57
 
61
- export { createServiceClient, getServiceUrl } from './service-client';
62
- export type { ServiceClientOptions, ControllerClient } from './service-client.types';
58
+ // Service Client
59
+ export * from './service-client';
63
60
 
64
- // ENV resolver
65
- export { resolveEnvOverrides, resolveEnvOverridesSync } from './env-resolver';
61
+ // Redis
62
+ export * from './redis';
66
63
 
67
- // WebSocket Gateway
68
- export { BaseWebSocketGateway } from './ws-base-gateway';
69
- export {
70
- WebSocketGateway,
71
- OnConnect,
72
- OnDisconnect,
73
- OnJoinRoom,
74
- OnLeaveRoom,
75
- OnMessage,
76
- Client,
77
- Socket,
78
- MessageData,
79
- RoomName,
80
- PatternParams,
81
- WsServer,
82
- UseWsGuards,
83
- getGatewayMetadata,
84
- isWebSocketGateway,
85
- } from './ws-decorators';
86
- export {
87
- WsAuthGuard,
88
- WsPermissionGuard,
89
- WsRoomGuard,
90
- WsAnyPermissionGuard,
91
- WsServiceGuard,
92
- WsAllGuards,
93
- WsAnyGuard,
94
- WsExecutionContextImpl,
95
- executeGuards,
96
- createGuard,
97
- } from './ws-guards';
98
- export type {
99
- WsClientData,
100
- WsAuthData,
101
- WsRoom,
102
- WsHandlerType,
103
- WsParamType,
104
- GatewayMetadata,
105
- WsHandlerMetadata,
106
- WsParamMetadata,
107
- WebSocketGatewayOptions,
108
- WsStorageOptions,
109
- WebSocketApplicationOptions,
110
- WsMessage,
111
- WsHandlerResponse,
112
- PatternMatch,
113
- WsExecutionContext,
114
- WsGuard,
115
- WsServer as WsServerType,
116
- } from './ws.types';
117
- export {
118
- WsHandlerType as WsHandlerTypeEnum,
119
- WsParamType as WsParamTypeEnum,
120
- isWsMessage,
121
- isWsHandlerResponse,
122
- isWsClientData,
123
- isWsRoom,
124
- } from './ws.types';
125
- export {
126
- matchPattern,
127
- isPatternMatch,
128
- createPatternMatcher,
129
- isPattern,
130
- getPatternParams,
131
- buildFromPattern,
132
- } from './ws-pattern-matcher';
133
- export type { WsStorageAdapter, WsPubSubStorageAdapter, WsStorageEventPayload } from './ws-storage';
134
- export { WsStorageEvent, isPubSubAdapter } from './ws-storage';
135
- export { InMemoryWsStorage, createInMemoryWsStorage } from './ws-storage-memory';
136
- export { RedisWsStorage, createRedisWsStorage } from './ws-storage-redis';
64
+ // WebSocket
65
+ export * from './websocket';
137
66
 
138
- // Redis Client (shared)
139
- export { RedisClient, createRedisClient } from './redis-client';
140
- export type { RedisClientOptions } from './redis-client';
141
- export {
142
- SharedRedisProvider, SharedRedisService, makeSharedRedisLayer, getSharedRedis,
143
- } from './shared-redis';
144
- export type { SharedRedisOptions } from './shared-redis';
67
+ // Queue System
68
+ export * from './queue';
145
69
 
146
- // WebSocket Service Definition and Client
147
- export {
148
- createWsServiceDefinition, getWsGatewayNames, getWsEventNames, getWsEndpoint,
149
- } from './ws-service-definition';
150
- export type { WsServiceDefinition, WsGatewayDefinition, WsEndpointMetadata } from './ws-service-definition';
151
- export { createWsClient } from './ws-client';
152
- export type {
153
- WsClientOptions,
154
- WsClient,
155
- WsGatewayClient,
156
- WsEventListener,
157
- WsClientEvent,
158
- WsClientEventListeners,
159
- TypedWsClient,
160
- } from './ws-client.types';
161
- export { WsConnectionState } from './ws-client.types';
70
+ // Validation
71
+ export * from './validation';
72
+
73
+ // Testing Utilities
74
+ export * from './testing';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Module System
3
+ *
4
+ * Core module, controller, and service abstractions.
5
+ */
6
+
7
+ export * from './module';
8
+ export * from './controller';
9
+ // Re-export Controller as BaseController for backward compatibility
10
+ export { Controller as BaseController } from './controller';
11
+ export * from './service';
12
+ export * from './config.service';
@@ -11,9 +11,10 @@ import {
11
11
  } from 'bun:test';
12
12
  import { Context } from 'effect';
13
13
 
14
- import { makeDevLogger } from '../../logger/src/logger';
14
+ import { makeDevLogger } from '@onebun/logger';
15
+
16
+ import { Module } from '../decorators/decorators';
15
17
 
16
- import { Module } from './decorators';
17
18
  import { OneBunModule } from './module';
18
19
  import { Service } from './service';
19
20
 
@@ -5,7 +5,7 @@ import {
5
5
  } from 'effect';
6
6
 
7
7
  import type { Controller } from './controller';
8
- import type { Module } from './types';
8
+ import type { ModuleInstance } from '../types';
9
9
 
10
10
  import {
11
11
  createSyncLogger,
@@ -21,14 +21,15 @@ import {
21
21
  getConstructorParamTypes,
22
22
  getModuleMetadata,
23
23
  registerControllerDependencies,
24
- } from './decorators';
24
+ } from '../decorators/decorators';
25
+ import { isWebSocketGateway } from '../websocket/ws-decorators';
26
+
25
27
  import { getServiceMetadata, getServiceTag } from './service';
26
- import { isWebSocketGateway } from './ws-decorators';
27
28
 
28
29
  /**
29
30
  * OneBun Module implementation
30
31
  */
31
- export class OneBunModule implements Module {
32
+ export class OneBunModule implements ModuleInstance {
32
33
  private rootLayer: Layer.Layer<never, never, unknown>;
33
34
  private controllers: Function[] = [];
34
35
  private controllerInstances: Map<Function, Controller> = new Map();
@@ -438,7 +439,7 @@ export class OneBunModule implements Module {
438
439
  moduleClass: Function,
439
440
  loggerLayer?: Layer.Layer<never, never, unknown>,
440
441
  config?: unknown,
441
- ): Module {
442
+ ): ModuleInstance {
442
443
  // Using console.log here because we don't have access to the logger instance yet
443
444
  // The instance will create its own logger in the constructor
444
445
  return new OneBunModule(moduleClass, loggerLayer, config);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Queue Adapters
3
+ *
4
+ * Built-in queue adapters for OneBun.
5
+ */
6
+
7
+ export { InMemoryQueueAdapter, createInMemoryQueueAdapter } from './memory.adapter';
8
+ export { RedisQueueAdapter, createRedisQueueAdapter, type RedisQueueOptions } from './redis.adapter';