@morojs/moro 1.3.0 → 1.5.0
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 +61 -7
- package/dist/core/config/index.d.ts +0 -1
- package/dist/core/config/index.js +0 -4
- package/dist/core/config/index.js.map +1 -1
- package/dist/core/config/loader.js +219 -226
- package/dist/core/config/loader.js.map +1 -1
- package/dist/core/config/schema.d.ts +30 -335
- package/dist/core/config/schema.js +133 -224
- package/dist/core/config/schema.js.map +1 -1
- package/dist/core/config/utils.d.ts +3 -2
- package/dist/core/config/utils.js.map +1 -1
- package/dist/core/config/validation.d.ts +17 -0
- package/dist/core/config/validation.js +129 -0
- package/dist/core/config/validation.js.map +1 -0
- package/dist/core/docs/index.js +1 -1
- package/dist/core/docs/index.js.map +1 -1
- package/dist/core/docs/openapi-generator.js +6 -6
- package/dist/core/docs/openapi-generator.js.map +1 -1
- package/dist/core/docs/schema-to-openapi.d.ts +7 -0
- package/dist/core/docs/schema-to-openapi.js +124 -0
- package/dist/core/docs/schema-to-openapi.js.map +1 -0
- package/dist/core/docs/simple-docs.js +5 -5
- package/dist/core/docs/zod-to-openapi.d.ts +4 -3
- package/dist/core/docs/zod-to-openapi.js +28 -0
- package/dist/core/docs/zod-to-openapi.js.map +1 -1
- package/dist/core/framework.d.ts +29 -6
- package/dist/core/framework.js +117 -18
- package/dist/core/framework.js.map +1 -1
- package/dist/core/networking/adapters/index.d.ts +3 -0
- package/dist/core/networking/adapters/index.js +10 -0
- package/dist/core/networking/adapters/index.js.map +1 -0
- package/dist/core/networking/adapters/socketio-adapter.d.ts +16 -0
- package/dist/core/networking/adapters/socketio-adapter.js +244 -0
- package/dist/core/networking/adapters/socketio-adapter.js.map +1 -0
- package/dist/core/networking/adapters/ws-adapter.d.ts +54 -0
- package/dist/core/networking/adapters/ws-adapter.js +383 -0
- package/dist/core/networking/adapters/ws-adapter.js.map +1 -0
- package/dist/core/networking/websocket-adapter.d.ts +171 -0
- package/dist/core/networking/websocket-adapter.js +5 -0
- package/dist/core/networking/websocket-adapter.js.map +1 -0
- package/dist/core/networking/websocket-manager.d.ts +53 -17
- package/dist/core/networking/websocket-manager.js +184 -126
- package/dist/core/networking/websocket-manager.js.map +1 -1
- package/dist/core/routing/index.d.ts +13 -13
- package/dist/core/routing/index.js.map +1 -1
- package/dist/core/validation/adapters.d.ts +51 -0
- package/dist/core/validation/adapters.js +135 -0
- package/dist/core/validation/adapters.js.map +1 -0
- package/dist/core/validation/index.d.ts +12 -11
- package/dist/core/validation/index.js +32 -26
- package/dist/core/validation/index.js.map +1 -1
- package/dist/core/validation/schema-interface.d.ts +36 -0
- package/dist/core/validation/schema-interface.js +68 -0
- package/dist/core/validation/schema-interface.js.map +1 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/moro.js +24 -17
- package/dist/moro.js.map +1 -1
- package/dist/types/config.d.ts +146 -0
- package/dist/types/config.js +4 -0
- package/dist/types/config.js.map +1 -0
- package/package.json +30 -7
- package/src/core/config/index.ts +0 -3
- package/src/core/config/loader.ts +571 -247
- package/src/core/config/schema.ts +146 -279
- package/src/core/config/utils.ts +1 -2
- package/src/core/config/validation.ts +140 -0
- package/src/core/docs/index.ts +1 -1
- package/src/core/docs/openapi-generator.ts +7 -6
- package/src/core/docs/schema-to-openapi.ts +148 -0
- package/src/core/docs/simple-docs.ts +5 -5
- package/src/core/docs/zod-to-openapi.ts +52 -20
- package/src/core/framework.ts +121 -28
- package/src/core/networking/adapters/index.ts +16 -0
- package/src/core/networking/adapters/socketio-adapter.ts +252 -0
- package/src/core/networking/adapters/ws-adapter.ts +425 -0
- package/src/core/networking/websocket-adapter.ts +217 -0
- package/src/core/networking/websocket-manager.ts +201 -143
- package/src/core/routing/index.ts +13 -13
- package/src/core/validation/adapters.ts +147 -0
- package/src/core/validation/index.ts +54 -38
- package/src/core/validation/schema-interface.ts +100 -0
- package/src/index.ts +36 -3
- package/src/moro.ts +27 -17
- package/src/types/config.ts +157 -0
package/README.md
CHANGED
|
@@ -25,7 +25,8 @@ Moro eliminates the pain points of traditional Node.js frameworks with **intelli
|
|
|
25
25
|
- **Multi-Runtime Support** - Deploy to Node.js, Vercel Edge, AWS Lambda, Cloudflare Workers
|
|
26
26
|
- **Intelligent Routing** - Chainable + schema-first APIs with automatic middleware ordering
|
|
27
27
|
- **Enterprise Authentication** - Auth.js integration with RBAC, OAuth, and native adapter
|
|
28
|
-
- **
|
|
28
|
+
- **Universal Validation** - Support for Zod, Joi, Yup, Class Validator with full TypeScript inference
|
|
29
|
+
- **WebSocket Support** - Pluggable adapters for Socket.IO, native WebSockets, or auto-detection
|
|
29
30
|
- **Native Performance** - Zero framework overhead, optimized for each runtime
|
|
30
31
|
- **Functional Architecture** - No decorators, pure functional patterns
|
|
31
32
|
- **Zero Order Dependencies** - Framework handles optimal middleware execution
|
|
@@ -127,20 +128,30 @@ app.post('/users')
|
|
|
127
128
|
.handler(createUser); // Always executed last
|
|
128
129
|
```
|
|
129
130
|
|
|
130
|
-
### **Full Type Safety
|
|
131
|
+
### **Universal Validation with Full Type Safety**
|
|
131
132
|
|
|
132
133
|
```typescript
|
|
134
|
+
// Use any validation library - Zod (default)
|
|
135
|
+
import { z } from '@morojs/moro';
|
|
133
136
|
const UserSchema = z.object({
|
|
134
137
|
name: z.string().min(2).max(50),
|
|
135
138
|
email: z.string().email(),
|
|
136
139
|
age: z.number().min(18).optional()
|
|
137
140
|
});
|
|
138
141
|
|
|
142
|
+
// Or Joi with adapter
|
|
143
|
+
import { joi } from '@morojs/moro';
|
|
144
|
+
import Joi from 'joi';
|
|
145
|
+
const UserSchema = joi(Joi.object({
|
|
146
|
+
name: Joi.string().min(2).max(50).required(),
|
|
147
|
+
email: Joi.string().email().required(),
|
|
148
|
+
age: Joi.number().min(18).optional()
|
|
149
|
+
}));
|
|
150
|
+
|
|
139
151
|
app.post('/users')
|
|
140
|
-
.body(UserSchema)
|
|
152
|
+
.body(UserSchema) // Works with any validation library!
|
|
141
153
|
.handler((req, res) => {
|
|
142
|
-
// req.body is typed
|
|
143
|
-
// Full IDE support, no type assertions needed!
|
|
154
|
+
// req.body is fully typed regardless of validation library
|
|
144
155
|
const user = req.body; // ✨ Fully typed
|
|
145
156
|
return { success: true, data: user };
|
|
146
157
|
});
|
|
@@ -168,6 +179,45 @@ app.route({
|
|
|
168
179
|
});
|
|
169
180
|
```
|
|
170
181
|
|
|
182
|
+
### WebSocket Support
|
|
183
|
+
|
|
184
|
+
Pluggable WebSocket adapters with auto-detection:
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { createApp, SocketIOAdapter, WSAdapter } from '@morojs/moro';
|
|
188
|
+
|
|
189
|
+
const app = createApp({
|
|
190
|
+
// Auto-detect available WebSocket library
|
|
191
|
+
websocket: { enabled: true },
|
|
192
|
+
|
|
193
|
+
// Or use specific adapter
|
|
194
|
+
websocket: { adapter: new SocketIOAdapter() },
|
|
195
|
+
|
|
196
|
+
// Or native WebSockets
|
|
197
|
+
websocket: { adapter: new WSAdapter() }
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// Define WebSocket handlers
|
|
201
|
+
app.websocket('/chat', {
|
|
202
|
+
connect: (socket) => {
|
|
203
|
+
console.log(`Client connected: ${socket.id}`);
|
|
204
|
+
socket.join('general');
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
message: (socket, data) => {
|
|
208
|
+
socket.to('general').emit('message', {
|
|
209
|
+
user: socket.user,
|
|
210
|
+
text: data.text,
|
|
211
|
+
timestamp: new Date()
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
disconnect: (socket) => {
|
|
216
|
+
console.log(`Client disconnected: ${socket.id}`);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
171
221
|
### Authentication & Security
|
|
172
222
|
|
|
173
223
|
Built-in Auth.js integration with enterprise features:
|
|
@@ -256,15 +306,19 @@ await app.loadModule(UsersModule);
|
|
|
256
306
|
- **Multi-Runtime Support** - Same API works on Node.js, Edge, Lambda, and Workers
|
|
257
307
|
- **Intelligent Routing** - Automatic middleware ordering eliminates Express.js pain points
|
|
258
308
|
- **Enterprise Authentication** - Auth.js integration with OAuth, RBAC, and native adapter
|
|
309
|
+
- **Universal Validation** - Support for any validation library with full type safety
|
|
310
|
+
- **WebSocket Flexibility** - Choose between Socket.IO, native WebSockets, or auto-detection
|
|
259
311
|
- **Functional Architecture** - No decorators, pure functions, better performance
|
|
260
|
-
- **Type Safety** -
|
|
312
|
+
- **Type Safety** - Universal validation with compile-time and runtime type safety
|
|
261
313
|
|
|
262
314
|
## Why Choose Moro?
|
|
263
315
|
|
|
264
316
|
**Same API everywhere** - Write once, deploy to any runtime
|
|
265
317
|
**No middleware dependencies** - Framework handles optimal ordering
|
|
266
318
|
**Enterprise authentication** - Auth.js integration with native adapter
|
|
267
|
-
**
|
|
319
|
+
**Validation flexibility** - Use any validation library (Zod, Joi, Yup, Class Validator)
|
|
320
|
+
**WebSocket choice** - Socket.IO, native WebSockets, or auto-detection
|
|
321
|
+
**Full type safety** - Universal validation provides end-to-end TypeScript inference
|
|
268
322
|
**Clean APIs** - Chainable and schema-first approaches
|
|
269
323
|
**Production ready** - Circuit breakers, rate limiting, events, RBAC
|
|
270
324
|
**Performance optimized** - Runtime-specific adapters
|
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.z = void 0;
|
|
18
17
|
exports.initializeConfig = initializeConfig;
|
|
19
18
|
exports.getGlobalConfig = getGlobalConfig;
|
|
20
19
|
exports.isConfigInitialized = isConfigInitialized;
|
|
@@ -24,9 +23,6 @@ __exportStar(require("./schema"), exports);
|
|
|
24
23
|
__exportStar(require("./loader"), exports);
|
|
25
24
|
__exportStar(require("./utils"), exports);
|
|
26
25
|
__exportStar(require("./file-loader"), exports);
|
|
27
|
-
// Re-export common Zod utilities for configuration
|
|
28
|
-
var zod_1 = require("zod");
|
|
29
|
-
Object.defineProperty(exports, "z", { enumerable: true, get: function () { return zod_1.z; } });
|
|
30
26
|
// Main configuration loading function
|
|
31
27
|
const loader_1 = require("./loader");
|
|
32
28
|
const utils_1 = require("./utils");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAkBA,4CAWC;AAMD,0CAKC;AAKD,kDAEC;AAMD,kCAMC;AA3DD,oDAAoD;AACpD,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,gDAA8B;AAE9B,sCAAsC;AACtC,qCAAsC;AAEtC,mCAAoC;AAEpC,gCAAgC;AAChC,IAAI,YAAY,GAAqB,IAAI,CAAC;AAE1C;;;GAGG;AACH,SAAgB,gBAAgB;IAC9B,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,YAAY,GAAG,IAAA,mBAAU,GAAE,CAAC;IAE5B,0CAA0C;IAC1C,IAAA,iBAAS,EAAC,YAAY,CAAC,CAAC;IAExB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB;IACjC,OAAO,YAAY,KAAK,IAAI,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,SAAgB,WAAW;IACzB,YAAY,GAAG,IAAI,CAAC;IAEpB,wEAAwE;IACxE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,SAAS,CAAC,IAAW,CAAC,CAAC;AACzB,CAAC"}
|