@morojs/moro 1.7.0 → 1.7.2

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 (46) hide show
  1. package/dist/core/auth/morojs-adapter.d.ts +8 -7
  2. package/dist/core/auth/morojs-adapter.js +92 -57
  3. package/dist/core/auth/morojs-adapter.js.map +1 -1
  4. package/dist/core/database/adapters/mysql.d.ts +1 -0
  5. package/dist/core/database/adapters/mysql.js +4 -0
  6. package/dist/core/database/adapters/mysql.js.map +1 -1
  7. package/dist/core/database/adapters/postgresql.d.ts +1 -0
  8. package/dist/core/database/adapters/postgresql.js +4 -0
  9. package/dist/core/database/adapters/postgresql.js.map +1 -1
  10. package/dist/core/database/adapters/sqlite.d.ts +1 -0
  11. package/dist/core/database/adapters/sqlite.js +4 -0
  12. package/dist/core/database/adapters/sqlite.js.map +1 -1
  13. package/dist/core/framework.js +9 -0
  14. package/dist/core/framework.js.map +1 -1
  15. package/dist/core/http/http-server.js +143 -0
  16. package/dist/core/http/http-server.js.map +1 -1
  17. package/dist/core/http/http2-server.js +143 -0
  18. package/dist/core/http/http2-server.js.map +1 -1
  19. package/dist/core/http/uws-http-server.js +143 -0
  20. package/dist/core/http/uws-http-server.js.map +1 -1
  21. package/dist/core/middleware/built-in/auth/core.d.ts +215 -4
  22. package/dist/core/middleware/built-in/auth/core.js +141 -8
  23. package/dist/core/middleware/built-in/auth/core.js.map +1 -1
  24. package/dist/core/middleware/built-in/auth/hook.d.ts +1 -1
  25. package/dist/core/middleware/built-in/auth/hook.js +10 -8
  26. package/dist/core/middleware/built-in/auth/hook.js.map +1 -1
  27. package/dist/core/middleware/built-in/auth/index.d.ts +1 -1
  28. package/dist/core/middleware/built-in/auth/index.js +1 -1
  29. package/dist/core/middleware/built-in/auth/index.js.map +1 -1
  30. package/dist/core/middleware/built-in/auth/middleware.js +1 -1
  31. package/dist/core/middleware/built-in/auth/middleware.js.map +1 -1
  32. package/dist/core/queue/adapters/memory-adapter.js +4 -0
  33. package/dist/core/queue/adapters/memory-adapter.js.map +1 -1
  34. package/dist/core/utilities/index.d.ts +2 -0
  35. package/dist/core/utilities/index.js +2 -0
  36. package/dist/core/utilities/index.js.map +1 -1
  37. package/dist/core/utilities/response-helpers.d.ts +280 -0
  38. package/dist/core/utilities/response-helpers.js +359 -0
  39. package/dist/core/utilities/response-helpers.js.map +1 -0
  40. package/dist/index.d.ts +4 -2
  41. package/dist/index.js +4 -2
  42. package/dist/index.js.map +1 -1
  43. package/dist/moro.js +21 -11
  44. package/dist/moro.js.map +1 -1
  45. package/dist/types/http.d.ts +21 -0
  46. package/package.json +11 -11
@@ -0,0 +1,280 @@
1
+ /**
2
+ * Standardized API Response Helpers
3
+ *
4
+ * These helpers ensure consistent response formats across your API.
5
+ * They are zero-overhead (just return plain objects) and optimized
6
+ * for the framework's fast-path JSON serialization.
7
+ *
8
+ * @module ResponseHelpers
9
+ */
10
+ /**
11
+ * Standard success response with data
12
+ */
13
+ export interface ApiSuccessResponse<T = any> {
14
+ success: true;
15
+ data: T;
16
+ message?: string;
17
+ }
18
+ /**
19
+ * Standard error response
20
+ */
21
+ export interface ApiErrorResponse {
22
+ success: false;
23
+ error: string;
24
+ code?: string;
25
+ message?: string;
26
+ details?: any;
27
+ }
28
+ /**
29
+ * Union type for all API responses
30
+ */
31
+ export type ApiResponse<T = any> = ApiSuccessResponse<T> | ApiErrorResponse;
32
+ /**
33
+ * Validation error detail
34
+ */
35
+ export interface ValidationErrorDetail {
36
+ field: string;
37
+ message: string;
38
+ code?: string;
39
+ }
40
+ /**
41
+ * Create a standardized success response
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * app.get('/users', async (req, res) => {
46
+ * const users = await getUsers();
47
+ * return success(users);
48
+ * });
49
+ *
50
+ * // With message
51
+ * app.post('/users', async (req, res) => {
52
+ * const user = await createUser(req.body);
53
+ * return success(user, 'User created successfully');
54
+ * });
55
+ * ```
56
+ */
57
+ export declare function success<T = any>(data: T, message?: string): ApiSuccessResponse<T>;
58
+ /**
59
+ * Create a standardized error response
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * app.get('/users/:id', async (req, res) => {
64
+ * const user = await getUser(req.params.id);
65
+ * if (!user) {
66
+ * return res.status(404).json(
67
+ * error('User not found', 'USER_NOT_FOUND')
68
+ * );
69
+ * }
70
+ * return success(user);
71
+ * });
72
+ * ```
73
+ */
74
+ export declare function error(errorMessage: string, code?: string, message?: string): ApiErrorResponse;
75
+ /**
76
+ * Create a validation error response
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * app.post('/users', async (req, res) => {
81
+ * const validationErrors = validateUser(req.body);
82
+ * if (validationErrors.length > 0) {
83
+ * return res.status(400).json(
84
+ * validationError(validationErrors)
85
+ * );
86
+ * }
87
+ * // ... create user
88
+ * });
89
+ * ```
90
+ */
91
+ export declare function validationError(details: ValidationErrorDetail[], message?: string): ApiErrorResponse;
92
+ /**
93
+ * Create an unauthorized error response
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * app.get('/admin', async (req, res) => {
98
+ * if (!req.user) {
99
+ * return res.status(401).json(unauthorized());
100
+ * }
101
+ * return success(adminData);
102
+ * });
103
+ * ```
104
+ */
105
+ export declare function unauthorized(message?: string): ApiErrorResponse;
106
+ /**
107
+ * Create a forbidden error response
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * app.delete('/users/:id', async (req, res) => {
112
+ * if (!req.user.roles.includes('admin')) {
113
+ * return res.status(403).json(forbidden());
114
+ * }
115
+ * await deleteUser(req.params.id);
116
+ * return success({ deleted: true });
117
+ * });
118
+ * ```
119
+ */
120
+ export declare function forbidden(message?: string): ApiErrorResponse;
121
+ /**
122
+ * Create a not found error response
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * app.get('/users/:id', async (req, res) => {
127
+ * const user = await getUser(req.params.id);
128
+ * if (!user) {
129
+ * return res.status(404).json(notFound('User'));
130
+ * }
131
+ * return success(user);
132
+ * });
133
+ * ```
134
+ */
135
+ export declare function notFound(resource?: string): ApiErrorResponse;
136
+ /**
137
+ * Create a conflict error response (e.g., duplicate entry)
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * app.post('/users', async (req, res) => {
142
+ * const existing = await getUserByEmail(req.body.email);
143
+ * if (existing) {
144
+ * return res.status(409).json(
145
+ * conflict('Email already in use')
146
+ * );
147
+ * }
148
+ * const user = await createUser(req.body);
149
+ * return success(user);
150
+ * });
151
+ * ```
152
+ */
153
+ export declare function conflict(message: string): ApiErrorResponse;
154
+ /**
155
+ * Create a bad request error response
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * app.post('/upload', async (req, res) => {
160
+ * if (!req.files?.file) {
161
+ * return res.status(400).json(
162
+ * badRequest('File is required')
163
+ * );
164
+ * }
165
+ * // ... process file
166
+ * });
167
+ * ```
168
+ */
169
+ export declare function badRequest(message?: string): ApiErrorResponse;
170
+ /**
171
+ * Create an internal server error response
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * app.get('/data', async (req, res) => {
176
+ * try {
177
+ * const data = await fetchData();
178
+ * return success(data);
179
+ * } catch (err) {
180
+ * return res.status(500).json(
181
+ * internalError('Failed to fetch data')
182
+ * );
183
+ * }
184
+ * });
185
+ * ```
186
+ */
187
+ export declare function internalError(message?: string): ApiErrorResponse;
188
+ /**
189
+ * Create a rate limit exceeded error response
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * app.post('/api/send', async (req, res) => {
194
+ * const limited = await checkRateLimit(req.ip);
195
+ * if (limited) {
196
+ * return res.status(429).json(
197
+ * rateLimited(60) // 60 seconds retry
198
+ * );
199
+ * }
200
+ * // ... process request
201
+ * });
202
+ * ```
203
+ */
204
+ export declare function rateLimited(retryAfter?: number): ApiErrorResponse;
205
+ /**
206
+ * Standardized response helper object for convenient imports
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * import { response } from '@morojs/moro';
211
+ *
212
+ * app.get('/users', async (req, res) => {
213
+ * const users = await getUsers();
214
+ * return response.success(users);
215
+ * });
216
+ *
217
+ * app.get('/users/:id', async (req, res) => {
218
+ * const user = await getUser(req.params.id);
219
+ * if (!user) {
220
+ * return res.status(404).json(response.notFound('User'));
221
+ * }
222
+ * return response.success(user);
223
+ * });
224
+ * ```
225
+ */
226
+ export declare const response: {
227
+ readonly success: typeof success;
228
+ readonly error: typeof error;
229
+ readonly validationError: typeof validationError;
230
+ readonly unauthorized: typeof unauthorized;
231
+ readonly forbidden: typeof forbidden;
232
+ readonly notFound: typeof notFound;
233
+ readonly conflict: typeof conflict;
234
+ readonly badRequest: typeof badRequest;
235
+ readonly internalError: typeof internalError;
236
+ readonly rateLimited: typeof rateLimited;
237
+ };
238
+ /**
239
+ * Type-safe response builder for complex scenarios
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * import { ResponseBuilder } from '@morojs/moro';
244
+ *
245
+ * app.get('/users', async (req, res) => {
246
+ * const users = await getUsers();
247
+ * return ResponseBuilder.success(users)
248
+ * .message('Successfully retrieved users')
249
+ * .build();
250
+ * });
251
+ * ```
252
+ */
253
+ export declare class ResponseBuilder<T = any> {
254
+ private response;
255
+ private constructor();
256
+ /**
257
+ * Start building a success response
258
+ */
259
+ static success<T>(data: T): ResponseBuilder<T>;
260
+ /**
261
+ * Start building an error response
262
+ */
263
+ static error(errorMessage: string, code?: string): ResponseBuilder<never>;
264
+ /**
265
+ * Add a message to the response
266
+ */
267
+ message(msg: string): this;
268
+ /**
269
+ * Add details to the response
270
+ */
271
+ details(details: any): this;
272
+ /**
273
+ * Add a code to error response
274
+ */
275
+ code(code: string): this;
276
+ /**
277
+ * Build and return the final response
278
+ */
279
+ build(): ApiResponse<T>;
280
+ }
@@ -0,0 +1,359 @@
1
+ /**
2
+ * Standardized API Response Helpers
3
+ *
4
+ * These helpers ensure consistent response formats across your API.
5
+ * They are zero-overhead (just return plain objects) and optimized
6
+ * for the framework's fast-path JSON serialization.
7
+ *
8
+ * @module ResponseHelpers
9
+ */
10
+ /**
11
+ * Create a standardized success response
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * app.get('/users', async (req, res) => {
16
+ * const users = await getUsers();
17
+ * return success(users);
18
+ * });
19
+ *
20
+ * // With message
21
+ * app.post('/users', async (req, res) => {
22
+ * const user = await createUser(req.body);
23
+ * return success(user, 'User created successfully');
24
+ * });
25
+ * ```
26
+ */
27
+ export function success(data, message) {
28
+ const response = {
29
+ success: true,
30
+ data,
31
+ };
32
+ if (message !== undefined) {
33
+ response.message = message;
34
+ }
35
+ return response;
36
+ }
37
+ /**
38
+ * Create a standardized error response
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * app.get('/users/:id', async (req, res) => {
43
+ * const user = await getUser(req.params.id);
44
+ * if (!user) {
45
+ * return res.status(404).json(
46
+ * error('User not found', 'USER_NOT_FOUND')
47
+ * );
48
+ * }
49
+ * return success(user);
50
+ * });
51
+ * ```
52
+ */
53
+ export function error(errorMessage, code, message) {
54
+ const response = {
55
+ success: false,
56
+ error: errorMessage,
57
+ };
58
+ if (code !== undefined) {
59
+ response.code = code;
60
+ }
61
+ if (message !== undefined) {
62
+ response.message = message;
63
+ }
64
+ return response;
65
+ }
66
+ /**
67
+ * Create a validation error response
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * app.post('/users', async (req, res) => {
72
+ * const validationErrors = validateUser(req.body);
73
+ * if (validationErrors.length > 0) {
74
+ * return res.status(400).json(
75
+ * validationError(validationErrors)
76
+ * );
77
+ * }
78
+ * // ... create user
79
+ * });
80
+ * ```
81
+ */
82
+ export function validationError(details, message) {
83
+ return {
84
+ success: false,
85
+ error: 'Validation failed',
86
+ code: 'VALIDATION_ERROR',
87
+ message: message || 'One or more fields failed validation',
88
+ details,
89
+ };
90
+ }
91
+ /**
92
+ * Create an unauthorized error response
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * app.get('/admin', async (req, res) => {
97
+ * if (!req.user) {
98
+ * return res.status(401).json(unauthorized());
99
+ * }
100
+ * return success(adminData);
101
+ * });
102
+ * ```
103
+ */
104
+ export function unauthorized(message = 'Authentication required') {
105
+ return {
106
+ success: false,
107
+ error: 'Unauthorized',
108
+ code: 'UNAUTHORIZED',
109
+ message,
110
+ };
111
+ }
112
+ /**
113
+ * Create a forbidden error response
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * app.delete('/users/:id', async (req, res) => {
118
+ * if (!req.user.roles.includes('admin')) {
119
+ * return res.status(403).json(forbidden());
120
+ * }
121
+ * await deleteUser(req.params.id);
122
+ * return success({ deleted: true });
123
+ * });
124
+ * ```
125
+ */
126
+ export function forbidden(message = 'Insufficient permissions') {
127
+ return {
128
+ success: false,
129
+ error: 'Forbidden',
130
+ code: 'FORBIDDEN',
131
+ message,
132
+ };
133
+ }
134
+ /**
135
+ * Create a not found error response
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * app.get('/users/:id', async (req, res) => {
140
+ * const user = await getUser(req.params.id);
141
+ * if (!user) {
142
+ * return res.status(404).json(notFound('User'));
143
+ * }
144
+ * return success(user);
145
+ * });
146
+ * ```
147
+ */
148
+ export function notFound(resource = 'Resource') {
149
+ return {
150
+ success: false,
151
+ error: 'Not Found',
152
+ code: 'NOT_FOUND',
153
+ message: `${resource} not found`,
154
+ };
155
+ }
156
+ /**
157
+ * Create a conflict error response (e.g., duplicate entry)
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * app.post('/users', async (req, res) => {
162
+ * const existing = await getUserByEmail(req.body.email);
163
+ * if (existing) {
164
+ * return res.status(409).json(
165
+ * conflict('Email already in use')
166
+ * );
167
+ * }
168
+ * const user = await createUser(req.body);
169
+ * return success(user);
170
+ * });
171
+ * ```
172
+ */
173
+ export function conflict(message) {
174
+ return {
175
+ success: false,
176
+ error: 'Conflict',
177
+ code: 'CONFLICT',
178
+ message,
179
+ };
180
+ }
181
+ /**
182
+ * Create a bad request error response
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * app.post('/upload', async (req, res) => {
187
+ * if (!req.files?.file) {
188
+ * return res.status(400).json(
189
+ * badRequest('File is required')
190
+ * );
191
+ * }
192
+ * // ... process file
193
+ * });
194
+ * ```
195
+ */
196
+ export function badRequest(message = 'Invalid request') {
197
+ return {
198
+ success: false,
199
+ error: 'Bad Request',
200
+ code: 'BAD_REQUEST',
201
+ message,
202
+ };
203
+ }
204
+ /**
205
+ * Create an internal server error response
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * app.get('/data', async (req, res) => {
210
+ * try {
211
+ * const data = await fetchData();
212
+ * return success(data);
213
+ * } catch (err) {
214
+ * return res.status(500).json(
215
+ * internalError('Failed to fetch data')
216
+ * );
217
+ * }
218
+ * });
219
+ * ```
220
+ */
221
+ export function internalError(message = 'Internal server error') {
222
+ return {
223
+ success: false,
224
+ error: 'Internal Server Error',
225
+ code: 'INTERNAL_ERROR',
226
+ message,
227
+ };
228
+ }
229
+ /**
230
+ * Create a rate limit exceeded error response
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * app.post('/api/send', async (req, res) => {
235
+ * const limited = await checkRateLimit(req.ip);
236
+ * if (limited) {
237
+ * return res.status(429).json(
238
+ * rateLimited(60) // 60 seconds retry
239
+ * );
240
+ * }
241
+ * // ... process request
242
+ * });
243
+ * ```
244
+ */
245
+ export function rateLimited(retryAfter) {
246
+ const response = {
247
+ success: false,
248
+ error: 'Too Many Requests',
249
+ code: 'RATE_LIMITED',
250
+ message: 'Rate limit exceeded',
251
+ };
252
+ if (retryAfter !== undefined) {
253
+ response.details = { retryAfter };
254
+ }
255
+ return response;
256
+ }
257
+ /**
258
+ * Standardized response helper object for convenient imports
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * import { response } from '@morojs/moro';
263
+ *
264
+ * app.get('/users', async (req, res) => {
265
+ * const users = await getUsers();
266
+ * return response.success(users);
267
+ * });
268
+ *
269
+ * app.get('/users/:id', async (req, res) => {
270
+ * const user = await getUser(req.params.id);
271
+ * if (!user) {
272
+ * return res.status(404).json(response.notFound('User'));
273
+ * }
274
+ * return response.success(user);
275
+ * });
276
+ * ```
277
+ */
278
+ export const response = {
279
+ success,
280
+ error,
281
+ validationError,
282
+ unauthorized,
283
+ forbidden,
284
+ notFound,
285
+ conflict,
286
+ badRequest,
287
+ internalError,
288
+ rateLimited,
289
+ };
290
+ /**
291
+ * Type-safe response builder for complex scenarios
292
+ *
293
+ * @example
294
+ * ```typescript
295
+ * import { ResponseBuilder } from '@morojs/moro';
296
+ *
297
+ * app.get('/users', async (req, res) => {
298
+ * const users = await getUsers();
299
+ * return ResponseBuilder.success(users)
300
+ * .message('Successfully retrieved users')
301
+ * .build();
302
+ * });
303
+ * ```
304
+ */
305
+ export class ResponseBuilder {
306
+ response = {};
307
+ constructor() { }
308
+ /**
309
+ * Start building a success response
310
+ */
311
+ static success(data) {
312
+ const builder = new ResponseBuilder();
313
+ builder.response = {
314
+ success: true,
315
+ data,
316
+ };
317
+ return builder;
318
+ }
319
+ /**
320
+ * Start building an error response
321
+ */
322
+ static error(errorMessage, code) {
323
+ const builder = new ResponseBuilder();
324
+ builder.response = {
325
+ success: false,
326
+ error: errorMessage,
327
+ code,
328
+ };
329
+ return builder;
330
+ }
331
+ /**
332
+ * Add a message to the response
333
+ */
334
+ message(msg) {
335
+ this.response.message = msg;
336
+ return this;
337
+ }
338
+ /**
339
+ * Add details to the response
340
+ */
341
+ details(details) {
342
+ this.response.details = details;
343
+ return this;
344
+ }
345
+ /**
346
+ * Add a code to error response
347
+ */
348
+ code(code) {
349
+ this.response.code = code;
350
+ return this;
351
+ }
352
+ /**
353
+ * Build and return the final response
354
+ */
355
+ build() {
356
+ return this.response;
357
+ }
358
+ }
359
+ //# sourceMappingURL=response-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-helpers.js","sourceRoot":"","sources":["../../../src/core/utilities/response-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoCH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,OAAO,CAAU,IAAO,EAAE,OAAgB;IACxD,MAAM,QAAQ,GAA0B;QACtC,O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Q;IACR,QAAQ;IACR,UAAU;IACV,aAAa;IACb,WAAW;CACH,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,eAAe;IAClB,QAAQ,GAA4B,EAAE,CAAC;IAE/C,gBAAuB,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,OAAO,CAAI,IAAO;QACvB,MAAM,OAAO,GAAG,IAAI,eAAe,EAAK,CAAC;QACzC,OAAO,CAAC,QAAQ,GAAG;YACjB,OAAO,EAAE,IAAI;YACb,IAAI;SACL,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,YAAoB,EAAE,IAAa;QAC9C,MAAM,OAAO,GAAG,IAAI,eAAe,EAAS,CAAC;QAC7C,OAAO,CAAC,QAAQ,GAAG;YACjB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,YAAY;YACnB,IAAI;SACL,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAW;QACjB,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,GAAG,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,OAAY;QACjB,IAAI,CAAC,QAA6B,CAAC,OAAO,GAAG,OAAO,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,IAAY;QACd,IAAI,CAAC,QAA6B,CAAC,IAAI,GAAG,IAAI,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,QAA0B,CAAC;IACzC,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,8 @@ export { Moro, Moro as MoroCore, createApp, createAppNode, createAppEdge, create
2
2
  export type { MoroOptions } from './core/framework.js';
3
3
  export type { AuthOptions, AuthProvider, AuthUser, AuthSession, AuthRequest, AuthAccount, AuthJWT, AuthCallbacks, AuthEvents, AuthPages, AuthAdapter, OAuthProvider, CredentialsProvider, EmailProvider, SignInOptions, SignOutOptions, } from './types/auth.js';
4
4
  export { createAuthMiddleware, MoroJSAuth } from './core/auth/morojs-adapter.js';
5
- export { auth, providers } from './core/middleware/built-in/auth/index.js';
5
+ export { auth, providers, twoFactor, organization, anonymous, accountLinking, rateLimit, bearerToken, } from './core/middleware/built-in/auth/index.js';
6
+ export type { TwoFactorAuthOptions, OrganizationOptions, AnonymousOptions, AccountLinkingOptions, RateLimitOptions, BearerTokenOptions, } from './core/middleware/built-in/auth/index.js';
6
7
  export type { RuntimeType, RuntimeAdapter, RuntimeConfig, RuntimeHttpResponse, } from './types/runtime.js';
7
8
  export { NodeRuntimeAdapter, VercelEdgeAdapter, AWSLambdaAdapter, CloudflareWorkersAdapter, createRuntimeAdapter, createNodeHandler, createEdgeHandler, createLambdaHandler, createWorkerHandler, } from './core/runtime/index.js';
8
9
  export type { LambdaEvent, LambdaContext, LambdaResponse, } from './core/runtime/aws-lambda-adapter.js';
@@ -11,7 +12,8 @@ export { MoroHttpServer, UWebSocketsHttpServer } from './core/http/index.js';
11
12
  export { builtInMiddleware, simpleMiddleware } from './core/middleware/built-in/index.js';
12
13
  export { WebSocketManager, ServiceRegistry } from './core/networking/index.js';
13
14
  export type { ServiceInfo, ServiceDiscoveryOptions } from './core/networking/service-discovery.js';
14
- export { Container, FunctionalContainer, ServiceScope, ServiceLifecycle, withLogging, withCaching, withRetry, withTimeout, CircuitBreaker, HookManager, HOOK_EVENTS, middleware, isPackageAvailable, resolveUserPackage, createUserRequire, } from './core/utilities/index.js';
15
+ export { Container, FunctionalContainer, ServiceScope, ServiceLifecycle, withLogging, withCaching, withRetry, withTimeout, CircuitBreaker, HookManager, HOOK_EVENTS, middleware, isPackageAvailable, resolveUserPackage, createUserRequire, response, ResponseBuilder, } from './core/utilities/index.js';
16
+ export type { ApiSuccessResponse, ApiErrorResponse, ApiResponse, ResponseValidationErrorDetail, } from './core/utilities/index.js';
15
17
  export { MoroEventBus } from './core/events/index.js';
16
18
  export type { EventContext, EventPayload, EventBusOptions, ModuleEventBus, GlobalEventBus, EventMetrics, SystemEvents, EventHandler, } from './types/events.js';
17
19
  export { createFrameworkLogger, logger } from './core/logger/index.js';
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ export { Moro, Moro as MoroCore, createApp, createAppNode, createAppEdge, create
3
3
  // Export native @auth/morojs adapter
4
4
  export { createAuthMiddleware, MoroJSAuth } from './core/auth/morojs-adapter.js';
5
5
  // Export Auth.js middleware and providers
6
- export { auth, providers } from './core/middleware/built-in/auth/index.js';
6
+ export { auth, providers, twoFactor, organization, anonymous, accountLinking, rateLimit, bearerToken, } from './core/middleware/built-in/auth/index.js';
7
7
  export { NodeRuntimeAdapter, VercelEdgeAdapter, AWSLambdaAdapter, CloudflareWorkersAdapter, createRuntimeAdapter, createNodeHandler, createEdgeHandler, createLambdaHandler, createWorkerHandler, } from './core/runtime/index.js';
8
8
  // Core exports
9
9
  export { MoroHttpServer, UWebSocketsHttpServer } from './core/http/index.js';
@@ -11,7 +11,9 @@ export { builtInMiddleware, simpleMiddleware } from './core/middleware/built-in/
11
11
  // Networking System
12
12
  export { WebSocketManager, ServiceRegistry } from './core/networking/index.js';
13
13
  // Utilities and Container System
14
- export { Container, FunctionalContainer, ServiceScope, ServiceLifecycle, withLogging, withCaching, withRetry, withTimeout, CircuitBreaker, HookManager, HOOK_EVENTS, middleware, isPackageAvailable, resolveUserPackage, createUserRequire, } from './core/utilities/index.js';
14
+ export { Container, FunctionalContainer, ServiceScope, ServiceLifecycle, withLogging, withCaching, withRetry, withTimeout, CircuitBreaker, HookManager, HOOK_EVENTS, middleware, isPackageAvailable, resolveUserPackage, createUserRequire,
15
+ // Standardized Response Helpers (namespace object only)
16
+ response, ResponseBuilder, } from './core/utilities/index.js';
15
17
  // Event System
16
18
  export { MoroEventBus } from './core/events/index.js';
17
19
  // Logger System
package/dist/index.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