raiton 3.1.1 → 4.0.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 +1 -1
- package/build/bin/index.mjs +138 -133
- package/package.json +3 -3
- package/scripts/update-version.ts +1 -1
- package/source/bin/bootstrapper.ts +1 -1
- package/source/commands/develop.command.ts +1 -1
- package/source/core/application.ts +2 -2
- package/source/core/builder.ts +3 -3
- package/source/core/config/define.ts +1 -1
- package/source/core/controller/builder.ts +1 -1
- package/source/core/controller/metadata.ts +1 -1
- package/source/core/index.ts +1 -0
- package/source/core/injection/injection.ts +2 -2
- package/source/core/middleware/compose.ts +1 -1
- package/source/core/router/handler.ts +5 -5
- package/source/core/router/router.ts +1 -1
- package/source/core/socket/index.ts +1 -0
- package/source/core/socket/metadata.ts +13 -0
- package/source/core/thread.ts +4 -4
- package/source/{sdk → framework}/artifacts.ts +1 -0
- package/source/{sdk → framework}/constants/decorators.constant.ts +2 -0
- package/source/{sdk → framework}/decorators/index.ts +1 -0
- package/source/framework/decorators/socket.decorator.ts +41 -0
- package/source/{sdk → framework}/utilities/artifact.util.ts +3 -0
- package/source/types/application.ts +1 -1
- package/source/types/controller.ts +1 -1
- package/source/types/index.ts +1 -0
- package/source/types/responses.ts +1 -1
- package/source/types/router.ts +1 -1
- package/source/types/runtime.ts +1 -1
- package/source/types/socket.ts +15 -0
- package/source/types/thread.ts +1 -1
- package/source/{sdk → framework}/constants/index.ts +0 -0
- package/source/{sdk → framework}/constants/microservices.constant.ts +0 -0
- package/source/{sdk → framework}/controllers.ts +0 -0
- package/source/{sdk → framework}/data-transfer-object.ts +0 -0
- package/source/{sdk → framework}/decorators/access-guard.decorator.ts +0 -0
- package/source/{sdk → framework}/decorators/controllable.decorator.ts +0 -0
- package/source/{sdk → framework}/decorators/guard.decorator.ts +0 -0
- package/source/{sdk → framework}/decorators/injection.decorator.ts +0 -0
- package/source/{sdk → framework}/decorators/middleware.decorator.ts +0 -0
- package/source/{sdk → framework}/decorators/parametrable.ts +0 -0
- package/source/{sdk → framework}/decorators/routable.decorator.ts +0 -0
- package/source/{sdk → framework}/encryption.ts +0 -0
- package/source/{sdk → framework}/enums/encrypted.enum.ts +0 -0
- package/source/{sdk → framework}/enums/event.message.enum.ts +0 -0
- package/source/{sdk → framework}/enums/http-method.enum.ts +0 -0
- package/source/{sdk → framework}/enums/http-parameters.enum.ts +0 -0
- package/source/{sdk → framework}/enums/http-status.enum.ts +0 -0
- package/source/{sdk → framework}/enums/index.ts +0 -0
- package/source/{sdk → framework}/enums/runtime.enum.ts +0 -0
- package/source/{sdk → framework}/enums/timestamp.enum.ts +0 -0
- package/source/{sdk → framework}/env.ts +0 -0
- package/source/{sdk → framework}/exceptions/http-exception.ts +0 -0
- package/source/{sdk → framework}/exceptions/index.ts +0 -0
- package/source/{sdk → framework}/exceptions/throwable.ts +0 -0
- package/source/{sdk → framework}/index.ts +2 -2
- /package/source/{sdk → framework}/parameter-bag.ts +0 -0
- /package/source/{sdk → framework}/plugins/body-parser.plugin.ts +0 -0
- /package/source/{sdk → framework}/plugins/index.ts +0 -0
- /package/source/{sdk → framework}/plugins/security/body-limit.ts +0 -0
- /package/source/{sdk → framework}/plugins/security/cors.ts +0 -0
- /package/source/{sdk → framework}/plugins/security/headers.ts +0 -0
- /package/source/{sdk → framework}/plugins/security/index.ts +0 -0
- /package/source/{sdk → framework}/plugins/security/method-guard.ts +0 -0
- /package/source/{sdk → framework}/plugins/security/rate-limit.ts +0 -0
- /package/source/{sdk → framework}/repositories.ts +0 -0
- /package/source/{sdk → framework}/responses/error.ts +0 -0
- /package/source/{sdk → framework}/responses/helpers.ts +0 -0
- /package/source/{sdk → framework}/responses/http-throwable.ts +0 -0
- /package/source/{sdk → framework}/responses/http.ts +0 -0
- /package/source/{sdk → framework}/responses/index.ts +0 -0
- /package/source/{sdk → framework}/runtime/bun/server.ts +0 -0
- /package/source/{sdk → framework}/runtime/deno/server.ts +0 -0
- /package/source/{sdk → framework}/runtime/index.ts +0 -0
- /package/source/{sdk → framework}/runtime/node/reply.ts +0 -0
- /package/source/{sdk → framework}/runtime/node/request.ts +0 -0
- /package/source/{sdk → framework}/runtime/node/server.ts +0 -0
- /package/source/{sdk → framework}/runtime/web/server.ts +0 -0
- /package/source/{sdk → framework}/services.ts +0 -0
- /package/source/{sdk → framework}/utilities/alias-path.util.ts +0 -0
- /package/source/{sdk → framework}/utilities/callable.util.ts +0 -0
- /package/source/{sdk → framework}/utilities/index.ts +0 -0
- /package/source/{sdk → framework}/utilities/json.util.ts +0 -0
- /package/source/{sdk → framework}/utilities/path.util.ts +0 -0
- /package/source/{sdk → framework}/utilities/url.ts +0 -0
- /package/source/{sdk → framework}/utilities/utilities.util.ts +0 -0
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ npm install raiton reflect-metadata
|
|
|
30
30
|
### 1. Créez un contrôleur (`source/controllers/hello.controller.ts`)
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
|
-
import { Controllable, Get, Param } from "raiton/
|
|
33
|
+
import { Controllable, Get, Param } from "raiton/framework";
|
|
34
34
|
|
|
35
35
|
@Controllable('/hello')
|
|
36
36
|
export class HelloController {
|
package/build/bin/index.mjs
CHANGED
|
@@ -3873,13 +3873,13 @@ var require_Reflect2 = __commonJS(() => {
|
|
|
3873
3873
|
}
|
|
3874
3874
|
return { value: undefined, done: true };
|
|
3875
3875
|
};
|
|
3876
|
-
MapIterator2.prototype.throw = function(
|
|
3876
|
+
MapIterator2.prototype.throw = function(error2) {
|
|
3877
3877
|
if (this._index >= 0) {
|
|
3878
3878
|
this._index = -1;
|
|
3879
3879
|
this._keys = arraySentinel;
|
|
3880
3880
|
this._values = arraySentinel;
|
|
3881
3881
|
}
|
|
3882
|
-
throw
|
|
3882
|
+
throw error2;
|
|
3883
3883
|
};
|
|
3884
3884
|
MapIterator2.prototype.return = function(value) {
|
|
3885
3885
|
if (this._index >= 0) {
|
|
@@ -4799,7 +4799,7 @@ var require_bcrypt = __commonJS((exports, module) => {
|
|
|
4799
4799
|
});
|
|
4800
4800
|
|
|
4801
4801
|
// source/bin/index.ts
|
|
4802
|
-
var
|
|
4802
|
+
var import_reflect_metadata6 = __toESM(require_Reflect(), 1);
|
|
4803
4803
|
|
|
4804
4804
|
// node_modules/commander/esm.mjs
|
|
4805
4805
|
var import__ = __toESM(require_commander(), 1);
|
|
@@ -4817,7 +4817,7 @@ var {
|
|
|
4817
4817
|
Help
|
|
4818
4818
|
} = import__.default;
|
|
4819
4819
|
// package.json
|
|
4820
|
-
var version = "
|
|
4820
|
+
var version = "4.0.0";
|
|
4821
4821
|
|
|
4822
4822
|
// source/bin/cli.ts
|
|
4823
4823
|
var CLI = new Command;
|
|
@@ -6211,7 +6211,7 @@ class RaitonConfig {
|
|
|
6211
6211
|
}
|
|
6212
6212
|
}
|
|
6213
6213
|
}
|
|
6214
|
-
// source/
|
|
6214
|
+
// source/framework/utilities/artifact.util.ts
|
|
6215
6215
|
function isControllerArtifact(filename) {
|
|
6216
6216
|
return isArtifact(filename, "controller");
|
|
6217
6217
|
}
|
|
@@ -6223,7 +6223,7 @@ function isArtifact(filename, artifact) {
|
|
|
6223
6223
|
filename.endsWith(`.${artifact}.cjs`)
|
|
6224
6224
|
].some(Boolean);
|
|
6225
6225
|
}
|
|
6226
|
-
// source/
|
|
6226
|
+
// source/framework/utilities/path.util.ts
|
|
6227
6227
|
import path2 from "node:path";
|
|
6228
6228
|
import { fileURLToPath } from "node:url";
|
|
6229
6229
|
function getDirname(importMetaUrl) {
|
|
@@ -6257,16 +6257,121 @@ class RaitonDirectories {
|
|
|
6257
6257
|
return path4.join(Raiton.thread?.builder.workdir || "", RaitonConfig.get("rootDir") || "./");
|
|
6258
6258
|
}
|
|
6259
6259
|
}
|
|
6260
|
-
// source/
|
|
6260
|
+
// source/framework/constants/decorators.constant.ts
|
|
6261
6261
|
var METADATA_KEYS = {
|
|
6262
6262
|
CONTROLLERS: Symbol("controller:meta"),
|
|
6263
|
+
SOCKETS: Symbol("socket:meta"),
|
|
6264
|
+
SOCKET_EVENTS: Symbol("socket:event:meta"),
|
|
6263
6265
|
ROUTE_PARAMETERS: Symbol("route:meta"),
|
|
6264
6266
|
GRAFTS: Symbol("graft:meta"),
|
|
6265
6267
|
CONTAINER: Symbol("container:meta"),
|
|
6266
6268
|
INJECT_PARAMETERS: Symbol("inject:parameters"),
|
|
6267
6269
|
INJECT_PROPERTIES: Symbol("inject:properties")
|
|
6268
6270
|
};
|
|
6269
|
-
// source/
|
|
6271
|
+
// source/framework/responses/http.ts
|
|
6272
|
+
class HttpResponse {
|
|
6273
|
+
response;
|
|
6274
|
+
static push(response) {
|
|
6275
|
+
throw new ThrowableResponse({
|
|
6276
|
+
statusCode: response.statusCode || 400 /* BAD_REQUEST */,
|
|
6277
|
+
message: response.message || "No response message provided",
|
|
6278
|
+
data: response.data,
|
|
6279
|
+
error: response.error,
|
|
6280
|
+
errorStack: response.errorStack
|
|
6281
|
+
});
|
|
6282
|
+
}
|
|
6283
|
+
constructor(response) {
|
|
6284
|
+
this.response = response;
|
|
6285
|
+
}
|
|
6286
|
+
status(statusCode) {
|
|
6287
|
+
this.response.statusCode = statusCode;
|
|
6288
|
+
return this;
|
|
6289
|
+
}
|
|
6290
|
+
message(message) {
|
|
6291
|
+
this.response.message = message;
|
|
6292
|
+
return this;
|
|
6293
|
+
}
|
|
6294
|
+
data(data) {
|
|
6295
|
+
this.response.data = data;
|
|
6296
|
+
return this;
|
|
6297
|
+
}
|
|
6298
|
+
error(error) {
|
|
6299
|
+
this.response.error = error;
|
|
6300
|
+
return this;
|
|
6301
|
+
}
|
|
6302
|
+
stack(stack) {
|
|
6303
|
+
this.response.errorStack = stack;
|
|
6304
|
+
return this;
|
|
6305
|
+
}
|
|
6306
|
+
render() {
|
|
6307
|
+
return new ThrowableResponse({ ...this.response }).render();
|
|
6308
|
+
}
|
|
6309
|
+
}
|
|
6310
|
+
|
|
6311
|
+
// source/framework/responses/error.ts
|
|
6312
|
+
class HttpErrorResponse {
|
|
6313
|
+
stack = new Map;
|
|
6314
|
+
get entries() {
|
|
6315
|
+
return [...this.stack.values()];
|
|
6316
|
+
}
|
|
6317
|
+
add(input) {
|
|
6318
|
+
this.stack.set(input.id, input);
|
|
6319
|
+
return this;
|
|
6320
|
+
}
|
|
6321
|
+
remove(id) {
|
|
6322
|
+
this.stack.delete(id);
|
|
6323
|
+
return this;
|
|
6324
|
+
}
|
|
6325
|
+
get(id) {
|
|
6326
|
+
return this.stack.get(id);
|
|
6327
|
+
}
|
|
6328
|
+
has(id) {
|
|
6329
|
+
return this.stack.has(id);
|
|
6330
|
+
}
|
|
6331
|
+
clear() {
|
|
6332
|
+
this.stack.clear();
|
|
6333
|
+
return this;
|
|
6334
|
+
}
|
|
6335
|
+
get empty() {
|
|
6336
|
+
return this.stack.size === 0;
|
|
6337
|
+
}
|
|
6338
|
+
get existence() {
|
|
6339
|
+
return this.stack.size;
|
|
6340
|
+
}
|
|
6341
|
+
push() {
|
|
6342
|
+
const first = this.stack.values().next().value;
|
|
6343
|
+
HttpResponse.push({
|
|
6344
|
+
statusCode: 500,
|
|
6345
|
+
message: first?.message || "Internal server error",
|
|
6346
|
+
error: true,
|
|
6347
|
+
errorStack: this.entries
|
|
6348
|
+
});
|
|
6349
|
+
}
|
|
6350
|
+
}
|
|
6351
|
+
// source/framework/responses/http-throwable.ts
|
|
6352
|
+
class ThrowableResponse extends Error {
|
|
6353
|
+
input;
|
|
6354
|
+
statusCode;
|
|
6355
|
+
constructor(input, statusCode = 500 /* INTERNAL_SERVER_ERROR */) {
|
|
6356
|
+
super(typeof input === "string" ? input : input.message);
|
|
6357
|
+
this.input = input;
|
|
6358
|
+
this.statusCode = statusCode;
|
|
6359
|
+
}
|
|
6360
|
+
render() {
|
|
6361
|
+
const stack = typeof this.input === "object" ? this.input.errorStack : undefined;
|
|
6362
|
+
return {
|
|
6363
|
+
message: this.message,
|
|
6364
|
+
statusCode: this.statusCode,
|
|
6365
|
+
data: typeof this.input === "object" ? this.input.data : undefined,
|
|
6366
|
+
error: typeof this.input === "object" ? this.input.error : false,
|
|
6367
|
+
stack: stack instanceof Error ? Raiton.thread?.builder?.options?.development ? this.stack?.split(`
|
|
6368
|
+
`).map((e) => e.trim()) : undefined : stack
|
|
6369
|
+
};
|
|
6370
|
+
}
|
|
6371
|
+
}
|
|
6372
|
+
// source/core/socket/metadata.ts
|
|
6373
|
+
var import_reflect_metadata = __toESM(require_Reflect2(), 1);
|
|
6374
|
+
// source/framework/decorators/routable.decorator.ts
|
|
6270
6375
|
function stabilizeRoute(meta, { path: path5, method, propertyKey }) {
|
|
6271
6376
|
return {
|
|
6272
6377
|
...meta.routes.filter((route) => route.path === path5 && route.method === method || route.propertyKey === propertyKey)[0] || {},
|
|
@@ -6294,8 +6399,8 @@ var Options = createRoutableDecorator("OPTIONS" /* OPTIONS */);
|
|
|
6294
6399
|
var Trace = createRoutableDecorator("TRACE" /* TRACE */);
|
|
6295
6400
|
var Delete = createRoutableDecorator("DELETE" /* DELETE */);
|
|
6296
6401
|
var Head = createRoutableDecorator("HEAD" /* HEAD */);
|
|
6297
|
-
// source/
|
|
6298
|
-
var
|
|
6402
|
+
// source/framework/decorators/parametrable.ts
|
|
6403
|
+
var import_reflect_metadata2 = __toESM(require_Reflect2(), 1);
|
|
6299
6404
|
function createRouteParametrableDecorator(type, callable2) {
|
|
6300
6405
|
return (key) => {
|
|
6301
6406
|
return (target, propertyKey, index) => {
|
|
@@ -6317,12 +6422,12 @@ var UploadedFile = createRouteParametrableDecorator("upload" /* UPLOAD_FILE */);
|
|
|
6317
6422
|
var Headers2 = createRouteParametrableDecorator("header" /* HEADER */);
|
|
6318
6423
|
var Req = createRouteParametrableDecorator("req" /* REQ */);
|
|
6319
6424
|
var Reply = createRouteParametrableDecorator("reply" /* REPLY */);
|
|
6320
|
-
// source/
|
|
6321
|
-
var
|
|
6425
|
+
// source/framework/decorators/injection.decorator.ts
|
|
6426
|
+
var import_reflect_metadata4 = __toESM(require_Reflect2(), 1);
|
|
6322
6427
|
|
|
6323
6428
|
// source/core/injection/injection.ts
|
|
6324
|
-
var
|
|
6325
|
-
// source/
|
|
6429
|
+
var import_reflect_metadata3 = __toESM(require_Reflect2(), 1);
|
|
6430
|
+
// source/framework/exceptions/throwable.ts
|
|
6326
6431
|
class Throwable extends Error {
|
|
6327
6432
|
statusCode;
|
|
6328
6433
|
constructor(message, statusCode = 500, label) {
|
|
@@ -6418,16 +6523,16 @@ class Injection {
|
|
|
6418
6523
|
continue;
|
|
6419
6524
|
}
|
|
6420
6525
|
if (typeof param === "function") {
|
|
6421
|
-
const
|
|
6422
|
-
const token2 =
|
|
6526
|
+
const metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTAINER, param);
|
|
6527
|
+
const token2 = metadata2?.name || param.name;
|
|
6423
6528
|
this.addDependent(token2, definition.name);
|
|
6424
6529
|
args.push(this.get(token2, effectiveScope));
|
|
6425
6530
|
continue;
|
|
6426
6531
|
}
|
|
6427
6532
|
}
|
|
6428
6533
|
if (designParam && typeof designParam === "function" && designParam.name) {
|
|
6429
|
-
const
|
|
6430
|
-
const token =
|
|
6534
|
+
const metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTAINER, designParam);
|
|
6535
|
+
const token = metadata2?.name || designParam.name;
|
|
6431
6536
|
this.addDependent(token, definition.name);
|
|
6432
6537
|
args.push(this.get(token, effectiveScope));
|
|
6433
6538
|
continue;
|
|
@@ -6492,8 +6597,8 @@ class Injection {
|
|
|
6492
6597
|
this.addDependent(token, definition.name);
|
|
6493
6598
|
instance[propertyKey] = this.get(token, scope);
|
|
6494
6599
|
} else if (typeof type === "function") {
|
|
6495
|
-
const
|
|
6496
|
-
const token_ =
|
|
6600
|
+
const metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTAINER, type);
|
|
6601
|
+
const token_ = metadata2?.name || type.name;
|
|
6497
6602
|
this.addDependent(token_, definition.name);
|
|
6498
6603
|
instance[propertyKey] = this.get(token_, scope);
|
|
6499
6604
|
}
|
|
@@ -6519,10 +6624,10 @@ class Injection {
|
|
|
6519
6624
|
this.clear();
|
|
6520
6625
|
}
|
|
6521
6626
|
static resolve(construct) {
|
|
6522
|
-
const
|
|
6523
|
-
if (!
|
|
6627
|
+
const metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTAINER, construct);
|
|
6628
|
+
if (!metadata2)
|
|
6524
6629
|
throw new Throwable(`Cannot resolve ${construct.name} as dependency`);
|
|
6525
|
-
return this.get(
|
|
6630
|
+
return this.get(metadata2.name);
|
|
6526
6631
|
}
|
|
6527
6632
|
}
|
|
6528
6633
|
// source/core/guards.ts
|
|
@@ -6561,107 +6666,6 @@ class RaitonGuards {
|
|
|
6561
6666
|
return this;
|
|
6562
6667
|
}
|
|
6563
6668
|
}
|
|
6564
|
-
// source/sdk/responses/http.ts
|
|
6565
|
-
class HttpResponse {
|
|
6566
|
-
response;
|
|
6567
|
-
static push(response) {
|
|
6568
|
-
throw new ThrowableResponse({
|
|
6569
|
-
statusCode: response.statusCode || 400 /* BAD_REQUEST */,
|
|
6570
|
-
message: response.message || "No response message provided",
|
|
6571
|
-
data: response.data,
|
|
6572
|
-
error: response.error,
|
|
6573
|
-
errorStack: response.errorStack
|
|
6574
|
-
});
|
|
6575
|
-
}
|
|
6576
|
-
constructor(response) {
|
|
6577
|
-
this.response = response;
|
|
6578
|
-
}
|
|
6579
|
-
status(statusCode) {
|
|
6580
|
-
this.response.statusCode = statusCode;
|
|
6581
|
-
return this;
|
|
6582
|
-
}
|
|
6583
|
-
message(message) {
|
|
6584
|
-
this.response.message = message;
|
|
6585
|
-
return this;
|
|
6586
|
-
}
|
|
6587
|
-
data(data) {
|
|
6588
|
-
this.response.data = data;
|
|
6589
|
-
return this;
|
|
6590
|
-
}
|
|
6591
|
-
error(error) {
|
|
6592
|
-
this.response.error = error;
|
|
6593
|
-
return this;
|
|
6594
|
-
}
|
|
6595
|
-
stack(stack) {
|
|
6596
|
-
this.response.errorStack = stack;
|
|
6597
|
-
return this;
|
|
6598
|
-
}
|
|
6599
|
-
render() {
|
|
6600
|
-
return new ThrowableResponse({ ...this.response }).render();
|
|
6601
|
-
}
|
|
6602
|
-
}
|
|
6603
|
-
|
|
6604
|
-
// source/sdk/responses/error.ts
|
|
6605
|
-
class HttpErrorResponse {
|
|
6606
|
-
stack = new Map;
|
|
6607
|
-
get entries() {
|
|
6608
|
-
return [...this.stack.values()];
|
|
6609
|
-
}
|
|
6610
|
-
add(input) {
|
|
6611
|
-
this.stack.set(input.id, input);
|
|
6612
|
-
return this;
|
|
6613
|
-
}
|
|
6614
|
-
remove(id) {
|
|
6615
|
-
this.stack.delete(id);
|
|
6616
|
-
return this;
|
|
6617
|
-
}
|
|
6618
|
-
get(id) {
|
|
6619
|
-
return this.stack.get(id);
|
|
6620
|
-
}
|
|
6621
|
-
has(id) {
|
|
6622
|
-
return this.stack.has(id);
|
|
6623
|
-
}
|
|
6624
|
-
clear() {
|
|
6625
|
-
this.stack.clear();
|
|
6626
|
-
return this;
|
|
6627
|
-
}
|
|
6628
|
-
get empty() {
|
|
6629
|
-
return this.stack.size === 0;
|
|
6630
|
-
}
|
|
6631
|
-
get existence() {
|
|
6632
|
-
return this.stack.size;
|
|
6633
|
-
}
|
|
6634
|
-
push() {
|
|
6635
|
-
const first = this.stack.values().next().value;
|
|
6636
|
-
HttpResponse.push({
|
|
6637
|
-
statusCode: 500,
|
|
6638
|
-
message: first?.message || "Internal server error",
|
|
6639
|
-
error: true,
|
|
6640
|
-
errorStack: this.entries
|
|
6641
|
-
});
|
|
6642
|
-
}
|
|
6643
|
-
}
|
|
6644
|
-
// source/sdk/responses/http-throwable.ts
|
|
6645
|
-
class ThrowableResponse extends Error {
|
|
6646
|
-
input;
|
|
6647
|
-
statusCode;
|
|
6648
|
-
constructor(input, statusCode = 500 /* INTERNAL_SERVER_ERROR */) {
|
|
6649
|
-
super(typeof input === "string" ? input : input.message);
|
|
6650
|
-
this.input = input;
|
|
6651
|
-
this.statusCode = statusCode;
|
|
6652
|
-
}
|
|
6653
|
-
render() {
|
|
6654
|
-
const stack = typeof this.input === "object" ? this.input.errorStack : undefined;
|
|
6655
|
-
return {
|
|
6656
|
-
message: this.message,
|
|
6657
|
-
statusCode: this.statusCode,
|
|
6658
|
-
data: typeof this.input === "object" ? this.input.data : undefined,
|
|
6659
|
-
error: typeof this.input === "object" ? this.input.error : false,
|
|
6660
|
-
stack: stack instanceof Error ? Raiton.thread?.builder?.options?.development ? this.stack?.split(`
|
|
6661
|
-
`).map((e) => e.trim()) : undefined : stack
|
|
6662
|
-
};
|
|
6663
|
-
}
|
|
6664
|
-
}
|
|
6665
6669
|
// source/core/hooks.ts
|
|
6666
6670
|
class HookStore {
|
|
6667
6671
|
hooks = new Map;
|
|
@@ -6889,7 +6893,7 @@ class PluginScope {
|
|
|
6889
6893
|
function definePlugin(setup, name) {
|
|
6890
6894
|
return { setup, name };
|
|
6891
6895
|
}
|
|
6892
|
-
// source/
|
|
6896
|
+
// source/framework/plugins/security/headers.ts
|
|
6893
6897
|
var secureHeaders = definePlugin((scope2) => {
|
|
6894
6898
|
scope2.use(async ({ context, next }) => {
|
|
6895
6899
|
context.reply.header("X-Content-Type-Options", "nosniff");
|
|
@@ -6899,20 +6903,20 @@ var secureHeaders = definePlugin((scope2) => {
|
|
|
6899
6903
|
await next();
|
|
6900
6904
|
});
|
|
6901
6905
|
}, "security-headers");
|
|
6902
|
-
// source/
|
|
6906
|
+
// source/framework/encryption.ts
|
|
6903
6907
|
var import_argon2 = __toESM(require_argon2(), 1);
|
|
6904
6908
|
var import_bcrypt = __toESM(require_bcrypt(), 1);
|
|
6905
6909
|
// source/core/controller/metadata.ts
|
|
6906
|
-
var
|
|
6910
|
+
var import_reflect_metadata5 = __toESM(require_Reflect2(), 1);
|
|
6907
6911
|
function getControllerMetadata(target) {
|
|
6908
|
-
let
|
|
6909
|
-
if (!
|
|
6910
|
-
|
|
6911
|
-
Reflect.defineMetadata(METADATA_KEYS.CONTROLLERS,
|
|
6912
|
+
let metadata2 = Reflect.getMetadata(METADATA_KEYS.CONTROLLERS, target);
|
|
6913
|
+
if (!metadata2) {
|
|
6914
|
+
metadata2 = { routes: [], middlewares: {} };
|
|
6915
|
+
Reflect.defineMetadata(METADATA_KEYS.CONTROLLERS, metadata2, target);
|
|
6912
6916
|
}
|
|
6913
|
-
return
|
|
6917
|
+
return metadata2;
|
|
6914
6918
|
}
|
|
6915
|
-
// source/
|
|
6919
|
+
// source/framework/artifacts.ts
|
|
6916
6920
|
class Artifacts {
|
|
6917
6921
|
static types = new Set;
|
|
6918
6922
|
static defaultTypes = [
|
|
@@ -6926,6 +6930,7 @@ class Artifacts {
|
|
|
6926
6930
|
"utility",
|
|
6927
6931
|
"source",
|
|
6928
6932
|
"controller",
|
|
6933
|
+
"socket",
|
|
6929
6934
|
"middleware",
|
|
6930
6935
|
"hook",
|
|
6931
6936
|
"event",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raiton",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading.",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
".": "./source/core/index.ts",
|
|
31
31
|
"./core/*": "./source/core/*.ts",
|
|
32
32
|
"./commands/*": "./source/commands/*.ts",
|
|
33
|
-
"./
|
|
34
|
-
"./
|
|
33
|
+
"./framework": "./source/framework/index.ts",
|
|
34
|
+
"./framework/*": "./source/framework/*.ts",
|
|
35
35
|
"./types": "./source/types/index.ts",
|
|
36
36
|
"./types/*": "./source/types/*.ts"
|
|
37
37
|
},
|
|
@@ -43,13 +43,13 @@ function determineIncrement(commits: string[]) {
|
|
|
43
43
|
}
|
|
44
44
|
if (
|
|
45
45
|
commit.startsWith("feat") ||
|
|
46
|
+
commit.startsWith("update") ||
|
|
46
47
|
commit.startsWith("add")
|
|
47
48
|
) {
|
|
48
49
|
increment = "minor";
|
|
49
50
|
} else if (
|
|
50
51
|
!increment &&
|
|
51
52
|
commit.startsWith("fix") ||
|
|
52
|
-
commit.startsWith("update") ||
|
|
53
53
|
commit.startsWith("remove")
|
|
54
54
|
) {
|
|
55
55
|
increment = "patch";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Raiton, RaitonCommand} from "../core";
|
|
2
2
|
import {ChildProcess, ChildProcessWithoutNullStreams} from 'node:child_process';
|
|
3
3
|
import {Logger} from "@protorians/logger";
|
|
4
|
-
import {EventMessageEnum} from "../
|
|
4
|
+
import {EventMessageEnum} from "../framework";
|
|
5
5
|
import {CliTools} from "../bin/cli-tools";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {PluginScope} from './plugins/scope'
|
|
2
2
|
import {RequestContext} from './context'
|
|
3
3
|
import {ApplicationConfigInterface, ApplicationInterface} from "../types/application";
|
|
4
|
-
import {HttpMethod} from "../
|
|
4
|
+
import {HttpMethod} from "../framework";
|
|
5
5
|
import {RouteHandlerCallable} from "../types";
|
|
6
6
|
import {Logger} from "@protorians/logger";
|
|
7
7
|
import {RaitonConfig} from "./config";
|
|
8
|
-
import {Artifacts} from "../
|
|
8
|
+
import {Artifacts} from "../framework/artifacts";
|
|
9
9
|
import {Injection} from "./injection";
|
|
10
10
|
|
|
11
11
|
export class Application implements ApplicationInterface {
|
package/source/core/builder.ts
CHANGED
|
@@ -5,13 +5,13 @@ import fs, {WatchEventType} from "node:fs";
|
|
|
5
5
|
import type {BuilderConfigInterface, BuilderInterface,} from "../types";
|
|
6
6
|
import {RaitonThread} from "./thread";
|
|
7
7
|
import {Raiton} from "./raiton";
|
|
8
|
-
import {isControllerArtifact, isServiceArtifact} from "../
|
|
8
|
+
import {isControllerArtifact, isServiceArtifact} from "../framework";
|
|
9
9
|
import {ControllerBuilder} from "./controller";
|
|
10
10
|
import {watch} from "fs";
|
|
11
11
|
import {LBadge, Logger} from "@protorians/logger";
|
|
12
|
-
import {Throwable} from "../
|
|
12
|
+
import {Throwable} from "../framework/exceptions";
|
|
13
13
|
import {Injection} from "./injection";
|
|
14
|
-
import {Artifacts} from "../
|
|
14
|
+
import {Artifacts} from "../framework/artifacts";
|
|
15
15
|
|
|
16
16
|
export class RaitonBuilder implements BuilderInterface {
|
|
17
17
|
protected _source: string | null = null;
|
|
@@ -4,7 +4,7 @@ import {LBadge, Logger} from "@protorians/logger";
|
|
|
4
4
|
import {compileController} from "./compiler";
|
|
5
5
|
import {RaitonThread} from "../thread";
|
|
6
6
|
import {Injection} from "../injection";
|
|
7
|
-
import {isControllerArtifact} from "../../
|
|
7
|
+
import {isControllerArtifact} from "../../framework";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
|
|
10
10
|
export class ControllerBuilder {
|
package/source/core/index.ts
CHANGED
|
@@ -2,8 +2,8 @@ import "reflect-metadata";
|
|
|
2
2
|
import type {ConstructorType, ContainerDefinitionInterface} from "../../types";
|
|
3
3
|
import {LifetimeEnum, TextUtility} from "@protorians/core";
|
|
4
4
|
import {Logger} from "@protorians/logger";
|
|
5
|
-
import {METADATA_KEYS} from "../../
|
|
6
|
-
import {Throwable} from "../../
|
|
5
|
+
import {METADATA_KEYS} from "../../framework/constants";
|
|
6
|
+
import {Throwable} from "../../framework/exceptions";
|
|
7
7
|
|
|
8
8
|
const camelCase = TextUtility.camelCase;
|
|
9
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {ControllerMetaInterface, MiddlewareCallable, ParamMetaInterface, RouteMetaInterface} from "../../types";
|
|
2
|
-
import {METADATA_KEYS, Parametrable} from "../../
|
|
2
|
+
import {METADATA_KEYS, Parametrable} from "../../framework";
|
|
3
3
|
import {Logger} from "@protorians/logger";
|
|
4
4
|
import {middlewareCompose, Raiton} from "..";
|
|
5
|
-
import {DataTransferObject} from "../../
|
|
6
|
-
import {Throwable} from "../../
|
|
7
|
-
import {HttpException} from "../../
|
|
8
|
-
import {ThrowableResponse} from "../../
|
|
5
|
+
import {DataTransferObject} from "../../framework/data-transfer-object";
|
|
6
|
+
import {Throwable} from "../../framework/exceptions/throwable";
|
|
7
|
+
import {HttpException} from "../../framework/exceptions";
|
|
8
|
+
import {ThrowableResponse} from "../../framework/responses/http-throwable";
|
|
9
9
|
|
|
10
10
|
export function createHandler(
|
|
11
11
|
instance: any,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./metadata"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {SocketMetaInterface} from "../../types";
|
|
2
|
+
import {METADATA_KEYS} from "../../framework";
|
|
3
|
+
import "reflect-metadata";
|
|
4
|
+
|
|
5
|
+
export function getSocketMetadata(target: any): SocketMetaInterface {
|
|
6
|
+
let metadata = Reflect.getMetadata(METADATA_KEYS.SOCKETS, target);
|
|
7
|
+
if (!metadata) {
|
|
8
|
+
metadata = { namespace: '/', events: [] };
|
|
9
|
+
Reflect.defineMetadata(METADATA_KEYS.SOCKETS, metadata, target);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return metadata;
|
|
13
|
+
}
|
package/source/core/thread.ts
CHANGED
|
@@ -7,16 +7,16 @@ import type {
|
|
|
7
7
|
ThreadSetupOptionsInterface,
|
|
8
8
|
ThreadWaitCallable,
|
|
9
9
|
} from "../types";
|
|
10
|
-
import {EventMessageEnum, RuntimeType} from "../
|
|
10
|
+
import {EventMessageEnum, RuntimeType} from "../framework/enums";
|
|
11
11
|
import {ProcessUtility} from "@protorians/core";
|
|
12
12
|
import {until} from "./process.util";
|
|
13
13
|
import {ApplicationInterface} from "../types/application";
|
|
14
|
-
import {Runtime} from "../
|
|
14
|
+
import {Runtime} from "../framework/runtime";
|
|
15
15
|
import {LBadge, Logger} from "@protorians/logger";
|
|
16
16
|
import {ControllerBuilder} from "./controller";
|
|
17
|
-
import {bodyParserPlugin} from "../
|
|
17
|
+
import {bodyParserPlugin} from "../framework/plugins/body-parser.plugin";
|
|
18
18
|
import {Injection} from "./injection/injection";
|
|
19
|
-
import {Throwable} from "../
|
|
19
|
+
import {Throwable} from "../framework/exceptions";
|
|
20
20
|
import os from "os";
|
|
21
21
|
|
|
22
22
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {getSocketMetadata} from "../../core/socket";
|
|
2
|
+
import {Injectable} from "..";
|
|
3
|
+
import {LifetimeEnum} from "@protorians/core";
|
|
4
|
+
import {SocketEventType} from "../../types";
|
|
5
|
+
|
|
6
|
+
export function Socket(namespace = '/') {
|
|
7
|
+
return (target: any) => {
|
|
8
|
+
const name = target.name;
|
|
9
|
+
Injectable(LifetimeEnum.TRANSIENT, name)(target)
|
|
10
|
+
|
|
11
|
+
const meta = getSocketMetadata(target.prototype || target)
|
|
12
|
+
meta.namespace = namespace;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function createSocketEventDecorator(type: SocketEventType, name?: string) {
|
|
17
|
+
return (target: any, propertyKey: string) => {
|
|
18
|
+
const meta = getSocketMetadata(target)
|
|
19
|
+
meta.events.push({
|
|
20
|
+
type,
|
|
21
|
+
name: name || propertyKey,
|
|
22
|
+
propertyKey
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function OnConnect() {
|
|
28
|
+
return createSocketEventDecorator('connect')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function OnDisconnect() {
|
|
32
|
+
return createSocketEventDecorator('disconnect')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function OnMessage(name?: string) {
|
|
36
|
+
return createSocketEventDecorator('message', name)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function OnEvent(name: string) {
|
|
40
|
+
return createSocketEventDecorator('event', name)
|
|
41
|
+
}
|
|
@@ -2,6 +2,9 @@ export function isControllerArtifact(filename: string) {
|
|
|
2
2
|
return isArtifact(filename, 'controller')
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
export function isSocketArtifact(filename: string) {
|
|
6
|
+
return isArtifact(filename, 'socket')
|
|
7
|
+
}
|
|
5
8
|
|
|
6
9
|
export function isServiceArtifact(filename: string) {
|
|
7
10
|
return isArtifact(filename, 'service')
|
package/source/types/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type * from "./plugin"
|
|
|
16
16
|
export type * from "./runtime"
|
|
17
17
|
export type * from "./router"
|
|
18
18
|
export type * from "./controller"
|
|
19
|
+
export type * from "./socket"
|
|
19
20
|
export type * from "./injection"
|
|
20
21
|
export type * from "./responses"
|
|
21
22
|
export type * from "./server"
|
package/source/types/router.ts
CHANGED
package/source/types/runtime.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
export interface SocketMetaInterface {
|
|
3
|
+
namespace: string;
|
|
4
|
+
events: SocketEventMetaInterface[];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface SocketEventMetaInterface {
|
|
8
|
+
name: string;
|
|
9
|
+
propertyKey: string;
|
|
10
|
+
type: SocketEventType;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type SocketEventType = 'message' | 'connect' | 'disconnect' | 'event';
|
|
14
|
+
|
|
15
|
+
export type SocketDecoratorCallable = (metadata: SocketMetaInterface) => void;
|
package/source/types/thread.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {BuilderInterface} from "./builder";
|
|
2
2
|
import {RuntimeAdapterInterface} from "./runtime";
|
|
3
3
|
import {ApplicationInterface} from "./application";
|
|
4
|
-
import {RuntimeType} from "../
|
|
4
|
+
import {RuntimeType} from "../framework/enums/runtime.enum";
|
|
5
5
|
|
|
6
6
|
export interface ThreadSetupOptionsInterface {
|
|
7
7
|
application: ApplicationInterface;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from "./enums/index"
|
|
2
2
|
export * from "./constants/index"
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./utilities/index"
|
|
4
4
|
export * from "./responses/index"
|
|
5
|
+
export * from "./decorators/index"
|
|
5
6
|
export * from "./plugins/index"
|
|
6
|
-
export * from "./utilities/index"
|
|
7
7
|
export * from "./runtime/index"
|
|
8
8
|
export * from "./exceptions/index"
|
|
9
9
|
export * from "./controllers"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|