raiton 6.6.0-beta.14 → 6.8.1-beta.17
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/CHANGELOG.md +30 -0
- package/README.md +16 -9
- package/build/bin/index.mjs +9150 -3911
- package/deno.json +4 -1
- package/docs/contributors/README.md +1 -0
- package/docs/contributors/core/README.md +8 -0
- package/docs/contributors/core/scheduler.md +113 -0
- package/docs/contributors/framework/README.md +2 -0
- package/docs/contributors/framework/cache/README.md +55 -0
- package/docs/contributors/framework/cache/cache.md +86 -0
- package/docs/contributors/framework/cache/etag.md +82 -0
- package/docs/contributors/framework/decorators/README.md +5 -0
- package/docs/contributors/framework/decorators/scheduler.md +83 -0
- package/docs/contributors/framework/runtime.md +13 -3
- package/docs/user-guide/README.md +9 -5
- package/docs/user-guide/cache.md +79 -0
- package/docs/user-guide/cli.md +35 -3
- package/docs/user-guide/decorators/README.md +3 -0
- package/docs/user-guide/decorators/cache.md +79 -0
- package/docs/user-guide/decorators/mcp.md +2 -2
- package/docs/user-guide/decorators/scheduler.md +75 -0
- package/docs/user-guide/mcp.md +2 -2
- package/docs/user-guide/runtime.md +2 -1
- package/docs/user-guide/scheduler.md +229 -0
- package/package.json +9 -4
- package/source/bin/bootstrapper.ts +4 -4
- package/source/bin/cli-tools.ts +27 -3
- package/source/bin/cli.ts +2 -2
- package/source/bin/commands.registry.ts +17 -0
- package/source/bin/constants.ts +1 -0
- package/source/bin/index.ts +2 -2
- package/source/commands/artifact.command.ts +2 -2
- package/source/commands/build.command.ts +2 -2
- package/source/commands/develop.command.ts +4 -5
- package/source/commands/grafts.command.ts +1 -1
- package/source/commands/start.command.ts +2 -2
- package/source/core/application.ts +10 -10
- package/source/core/artifacts/artifact.ts +1 -1
- package/source/core/artifacts/index.ts +1 -1
- package/source/core/builder.ts +81 -15
- package/source/core/bytes.util.ts +1 -1
- package/source/core/commands.ts +24 -14
- package/source/core/config/config.ts +2 -2
- package/source/core/config/define.ts +2 -2
- package/source/core/config/index.ts +2 -2
- package/source/core/context.ts +1 -1
- package/source/core/controller/builder.ts +16 -10
- package/source/core/controller/compiler.ts +6 -6
- package/source/core/controller/index.ts +4 -4
- package/source/core/controller/metadata.ts +2 -2
- package/source/core/controller/tracker.ts +1 -1
- package/source/core/directories.ts +3 -2
- package/source/core/guards.ts +1 -1
- package/source/core/helpers/index.ts +1 -1
- package/source/core/hooks.ts +1 -1
- package/source/core/index.ts +17 -16
- package/source/core/injection/index.ts +1 -1
- package/source/core/injection/injection.ts +7 -4
- package/source/core/mcp/builder.ts +8 -8
- package/source/core/mcp/index.ts +3 -3
- package/source/core/mcp/metadata.ts +2 -2
- package/source/core/mcp/tracker.ts +1 -1
- package/source/core/middleware/compose.ts +2 -2
- package/source/core/middleware/index.ts +2 -2
- package/source/core/middleware/pipeline.ts +2 -2
- package/source/core/plugins/index.ts +2 -2
- package/source/core/plugins/plugin.ts +1 -1
- package/source/core/plugins/scope.ts +4 -4
- package/source/core/raiton.ts +1 -1
- package/source/core/router/handler.ts +30 -6
- package/source/core/router/handler.utils.ts +3 -3
- package/source/core/router/index.ts +4 -4
- package/source/core/router/matcher.ts +1 -1
- package/source/core/router/route.ts +1 -1
- package/source/core/router/router.ts +4 -4
- package/source/core/scheduler/builder.ts +25 -0
- package/source/core/scheduler/cron.ts +400 -0
- package/source/core/scheduler/duration.ts +42 -0
- package/source/core/scheduler/index.ts +6 -0
- package/source/core/scheduler/manager.ts +542 -0
- package/source/core/scheduler/metadata.ts +53 -0
- package/source/core/scheduler/queue/backend.ts +142 -0
- package/source/core/scheduler/queue/index.ts +3 -0
- package/source/core/scheduler/queue/rabbitmq.backend.ts +124 -0
- package/source/core/scheduler/queue/redis.backend.ts +144 -0
- package/source/core/server.ts +1 -1
- package/source/core/socket/builder.ts +2 -2
- package/source/core/socket/index.ts +2 -2
- package/source/core/socket/metadata.ts +2 -2
- package/source/core/thread.ts +55 -22
- package/source/framework/artifacts.ts +32 -5
- package/source/framework/cache/cache.decorator.ts +35 -0
- package/source/framework/cache/cache.ts +197 -0
- package/source/framework/cache/etag.ts +174 -0
- package/source/framework/cache/index.ts +4 -0
- package/source/framework/cache/types.ts +111 -0
- package/source/framework/constants/decorators.constant.ts +4 -0
- package/source/framework/constants/index.ts +2 -2
- package/source/framework/decorators/access-guard.decorator.ts +2 -2
- package/source/framework/decorators/api-response.decorator.ts +1 -1
- package/source/framework/decorators/api.decorator.ts +1 -1
- package/source/framework/decorators/controllable.decorator.ts +3 -3
- package/source/framework/decorators/csrf-guard.decorator.ts +4 -4
- package/source/framework/decorators/csrf-token.decorator.ts +1 -1
- package/source/framework/decorators/guard.decorator.ts +4 -4
- package/source/framework/decorators/health-check.decorator.ts +3 -3
- package/source/framework/decorators/index.ts +15 -14
- package/source/framework/decorators/injection.decorator.ts +3 -3
- package/source/framework/decorators/mcp.decorator.ts +4 -4
- package/source/framework/decorators/middleware.decorator.ts +2 -2
- package/source/framework/decorators/parametrable.decorator.ts +2 -2
- package/source/framework/decorators/routable.decorator.ts +3 -3
- package/source/framework/decorators/route-interaction.decorator.ts +4 -4
- package/source/framework/decorators/scheduler.decorator.ts +139 -0
- package/source/framework/decorators/socket.decorator.ts +3 -3
- package/source/framework/encryption.ts +2 -2
- package/source/framework/enums/index.ts +9 -8
- package/source/framework/enums/runtime.enum.ts +1 -2
- package/source/framework/enums/scheduler.enum.ts +23 -0
- package/source/framework/env.ts +2 -2
- package/source/framework/exceptions/http-exception.ts +3 -3
- package/source/framework/exceptions/index.ts +2 -2
- package/source/framework/health-check.ts +4 -4
- package/source/framework/index.ts +18 -17
- package/source/framework/mcp/handler.ts +3 -3
- package/source/framework/mcp/index.ts +3 -3
- package/source/framework/mcp/protocol.ts +1 -1
- package/source/framework/mcp/streamable-http.ts +3 -3
- package/source/framework/parameter-bag.ts +2 -2
- package/source/framework/plugins/body-parser.plugin.ts +3 -3
- package/source/framework/plugins/index.ts +4 -4
- package/source/framework/plugins/mcp.plugin.ts +5 -5
- package/source/framework/plugins/openapi.plugin.ts +4 -4
- package/source/framework/plugins/security/body-limit.ts +3 -3
- package/source/framework/plugins/security/cors.ts +2 -2
- package/source/framework/plugins/security/csrf.ts +6 -6
- package/source/framework/plugins/security/headers.ts +2 -2
- package/source/framework/plugins/security/index.ts +6 -6
- package/source/framework/plugins/security/method-guard.ts +3 -3
- package/source/framework/plugins/security/rate-limit.ts +3 -3
- package/source/framework/repositories.ts +1 -1
- package/source/framework/responses/error.ts +2 -2
- package/source/framework/responses/helpers.ts +3 -3
- package/source/framework/responses/http-throwable.ts +3 -3
- package/source/framework/responses/http.ts +3 -3
- package/source/framework/responses/index.ts +4 -4
- package/source/framework/runtime/bun/server.ts +5 -5
- package/source/framework/runtime/deno/server.ts +156 -96
- package/source/framework/runtime/index.ts +11 -17
- package/source/framework/runtime/node/reply.ts +1 -1
- package/source/framework/runtime/node/request.ts +2 -2
- package/source/framework/runtime/node/server.ts +3 -3
- package/source/framework/runtime/web/server.ts +2 -2
- package/source/framework/services.ts +1 -1
- package/source/framework/utilities/artifact.util.ts +4 -0
- package/source/framework/utilities/csrf.util.ts +1 -1
- package/source/framework/utilities/index.ts +10 -10
- package/source/framework/utilities/openapi.utils.ts +7 -7
- package/source/framework/utilities/utilities.util.ts +1 -1
- package/source/types/application.ts +2 -2
- package/source/types/builder.ts +1 -1
- package/source/types/config.ts +1 -1
- package/source/types/controller.ts +3 -3
- package/source/types/core.ts +1 -1
- package/source/types/csrf.ts +1 -1
- package/source/types/guard.ts +1 -1
- package/source/types/http-responses.ts +1 -1
- package/source/types/index.ts +27 -26
- package/source/types/injection.ts +1 -1
- package/source/types/middleware.ts +1 -1
- package/source/types/plugin.ts +1 -1
- package/source/types/raiton.ts +2 -1
- package/source/types/responses.ts +2 -2
- package/source/types/router.ts +2 -2
- package/source/types/runtime.ts +3 -5
- package/source/types/scheduler.ts +180 -0
- package/source/types/thread.ts +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {getControllerMetadata} from "../../core";
|
|
2
|
-
import {HttpMethod} from "
|
|
3
|
-
import {ControllerMetaInterface, RouteDecoratorCallable, RouteMetaInterface} from "../../types";
|
|
1
|
+
import {getControllerMetadata} from "../../core/index.ts";
|
|
2
|
+
import {HttpMethod} from "../index.ts";
|
|
3
|
+
import {ControllerMetaInterface, RouteDecoratorCallable, RouteMetaInterface} from "../../types/index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
function stabilizeRoute(meta: ControllerMetaInterface, {path, method, propertyKey}: Partial<RouteMetaInterface>) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import {METADATA_KEYS} from "../constants/decorators.constant";
|
|
3
|
-
import {getControllerMetadata} from "../../core/controller";
|
|
4
|
-
import {RouteInteractionsSubscriber} from "../../types/router";
|
|
5
|
-
import { Raiton } from "../../core/raiton";
|
|
2
|
+
import {METADATA_KEYS} from "../constants/decorators.constant.ts";
|
|
3
|
+
import {getControllerMetadata} from "../../core/controller/index.ts";
|
|
4
|
+
import {RouteInteractionsSubscriber} from "../../types/router.ts";
|
|
5
|
+
import { Raiton } from "../../core/raiton.ts";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Represents a route interaction that can be rendered with context data
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import {getSchedulerMetadata, registerScheduler, unregisterScheduler} from "../../core/scheduler/index.ts";
|
|
3
|
+
import {Injectable} from "./index.ts";
|
|
4
|
+
import {LifetimeEnum} from "@protorians/core";
|
|
5
|
+
import {parseDuration} from "../../core/scheduler/duration.ts";
|
|
6
|
+
import {TaskTriggerEnum} from "../enums/index.ts";
|
|
7
|
+
import type {
|
|
8
|
+
CronOptionsInterface,
|
|
9
|
+
IntervalOptionsInterface,
|
|
10
|
+
JobMetaInterface,
|
|
11
|
+
SchedulerOptionsInterface,
|
|
12
|
+
TaskDeclarationInterface,
|
|
13
|
+
TimeoutOptionsInterface,
|
|
14
|
+
} from "../../types/index.ts";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Marks a class as a scheduler: a container for scheduled jobs
|
|
18
|
+
* ({@link Cron}, {@link Every}, {@link Timeout}) and named tasks
|
|
19
|
+
* ({@link Task}).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* @Scheduler({ name: 'maintenance', queue: 'default' })
|
|
24
|
+
* class MaintenanceScheduler {
|
|
25
|
+
* @Cron('0 0 * * *', { name: 'daily-cleanup' })
|
|
26
|
+
* async cleanup(ctx: TaskContextInterface) { ... }
|
|
27
|
+
*
|
|
28
|
+
* @Every('5m', { name: 'heartbeat' })
|
|
29
|
+
* async heartbeat() { ... }
|
|
30
|
+
*
|
|
31
|
+
* @Task('send-email', { consume: true, queue: 'emails' })
|
|
32
|
+
* async sendEmail(ctx: TaskContextInterface<Email>) { ... }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function Scheduler(options: SchedulerOptionsInterface = {}) {
|
|
37
|
+
return (target: any) => {
|
|
38
|
+
const name = options.name || target.name;
|
|
39
|
+
Injectable(LifetimeEnum.TRANSIENT, name)(target);
|
|
40
|
+
|
|
41
|
+
const meta = getSchedulerMetadata(target.prototype || target);
|
|
42
|
+
meta.name = name;
|
|
43
|
+
meta.queue = options.queue || 'default';
|
|
44
|
+
meta.timezone = options.timezone;
|
|
45
|
+
|
|
46
|
+
unregisterScheduler(name);
|
|
47
|
+
registerScheduler(target);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Schedule a method using a cron expression (5 or 6 fields).
|
|
53
|
+
*/
|
|
54
|
+
export function Cron(expression: string, options: CronOptionsInterface = {}) {
|
|
55
|
+
return (target: any, propertyKey: string) => {
|
|
56
|
+
const meta = getSchedulerMetadata(target);
|
|
57
|
+
const job: JobMetaInterface = {
|
|
58
|
+
propertyKey,
|
|
59
|
+
name: options.name || `${meta.name}:${propertyKey}`,
|
|
60
|
+
type: TaskTriggerEnum.Cron,
|
|
61
|
+
cron: expression,
|
|
62
|
+
queue: options.queue,
|
|
63
|
+
options,
|
|
64
|
+
};
|
|
65
|
+
meta.jobs.push(job);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Schedule a method at a fixed interval. `interval` is a number of
|
|
71
|
+
* milliseconds or a human-readable duration such as `"5s"` or `"1h"`.
|
|
72
|
+
*/
|
|
73
|
+
export function Every(interval: number | string, options: IntervalOptionsInterface = {}) {
|
|
74
|
+
return (target: any, propertyKey: string) => {
|
|
75
|
+
const meta = getSchedulerMetadata(target);
|
|
76
|
+
const job: JobMetaInterface = {
|
|
77
|
+
propertyKey,
|
|
78
|
+
name: options.name || `${meta.name}:${propertyKey}`,
|
|
79
|
+
type: TaskTriggerEnum.Interval,
|
|
80
|
+
interval: parseDuration(interval),
|
|
81
|
+
queue: options.queue,
|
|
82
|
+
options,
|
|
83
|
+
};
|
|
84
|
+
meta.jobs.push(job);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Schedule a one-shot method after a delay. `delay` is a number of
|
|
90
|
+
* milliseconds or a human-readable duration such as `"30s"`.
|
|
91
|
+
*/
|
|
92
|
+
export function Timeout(delay: number | string, options: TimeoutOptionsInterface = {}) {
|
|
93
|
+
return (target: any, propertyKey: string) => {
|
|
94
|
+
const meta = getSchedulerMetadata(target);
|
|
95
|
+
const job: JobMetaInterface = {
|
|
96
|
+
propertyKey,
|
|
97
|
+
name: options.name || `${meta.name}:${propertyKey}`,
|
|
98
|
+
type: TaskTriggerEnum.Timeout,
|
|
99
|
+
delay: parseDuration(delay),
|
|
100
|
+
queue: options.queue,
|
|
101
|
+
options,
|
|
102
|
+
};
|
|
103
|
+
meta.jobs.push(job);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Register a named task. Tasks are dispatachable in-process
|
|
109
|
+
* (`SchedulerManager.current.dispatch(name, payload)`), enqueueable on a
|
|
110
|
+
* queue backend (`SchedulerManager.current.enqueue(name, payload)`) and,
|
|
111
|
+
* when `options.consume` is `true`, consumed from the queue as a worker.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* @Scheduler()
|
|
116
|
+
* class Jobs {
|
|
117
|
+
* @Task('email:welcome', { queue: 'emails', consume: true, retries: 3 })
|
|
118
|
+
* async welcome(ctx: TaskContextInterface) { ... }
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export function Task(name: string, options: TaskDeclarationInterface = {}) {
|
|
123
|
+
return (target: any, propertyKey: string) => {
|
|
124
|
+
const meta = getSchedulerMetadata(target);
|
|
125
|
+
const job: JobMetaInterface = {
|
|
126
|
+
propertyKey,
|
|
127
|
+
name,
|
|
128
|
+
type: TaskTriggerEnum.Task,
|
|
129
|
+
queue: options.queue,
|
|
130
|
+
options: {
|
|
131
|
+
...options,
|
|
132
|
+
name,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
meta.jobs.push(job);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export {Every as Interval};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {getSocketMetadata, registerSocket} from "../../core/socket";
|
|
2
|
-
import {Injectable} from "
|
|
1
|
+
import {getSocketMetadata, registerSocket} from "../../core/socket/index.ts";
|
|
2
|
+
import {Injectable} from "../index.ts";
|
|
3
3
|
import {LifetimeEnum} from "@protorians/core";
|
|
4
|
-
import {SocketEventType} from "../../types";
|
|
4
|
+
import {SocketEventType} from "../../types/index.ts";
|
|
5
5
|
|
|
6
6
|
export function Socket(namespace = '/') {
|
|
7
7
|
return (target: any) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import argon2, {Options} from "argon2";
|
|
3
|
-
import {HashAlgoEnum, PasswordAlgoEnum} from "./enums";
|
|
3
|
+
import {HashAlgoEnum, PasswordAlgoEnum} from "./enums/index.ts";
|
|
4
4
|
import bcrypt from "bcrypt";
|
|
5
|
-
import {DerivationOptionsInterface, EncryptionResultType, ScryptOptionsInterface} from "../types";
|
|
5
|
+
import {DerivationOptionsInterface, EncryptionResultType, ScryptOptionsInterface} from "../types/index.ts";
|
|
6
6
|
|
|
7
7
|
export class Encryption {
|
|
8
8
|
static get algos() {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from "./http-method.enum"
|
|
2
|
-
export * from "./http-parameters.enum"
|
|
3
|
-
export * from "./http-status.enum"
|
|
4
|
-
export * from "./encrypted.enum"
|
|
5
|
-
export * from "./event.message.enum"
|
|
6
|
-
export * from "./timestamp.enum"
|
|
7
|
-
export * from "./runtime.enum"
|
|
8
|
-
export * from "./csrf.enum"
|
|
1
|
+
export * from "./http-method.enum.ts"
|
|
2
|
+
export * from "./http-parameters.enum.ts"
|
|
3
|
+
export * from "./http-status.enum.ts"
|
|
4
|
+
export * from "./encrypted.enum.ts"
|
|
5
|
+
export * from "./event.message.enum.ts"
|
|
6
|
+
export * from "./timestamp.enum.ts"
|
|
7
|
+
export * from "./runtime.enum.ts"
|
|
8
|
+
export * from "./csrf.enum.ts"
|
|
9
|
+
export * from "./scheduler.enum.ts"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export enum TaskTriggerEnum {
|
|
2
|
+
Cron = 'cron',
|
|
3
|
+
Interval = 'interval',
|
|
4
|
+
Timeout = 'timeout',
|
|
5
|
+
Task = 'task',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export enum TaskStatusEnum {
|
|
9
|
+
Pending = 'pending',
|
|
10
|
+
Running = 'running',
|
|
11
|
+
Completed = 'completed',
|
|
12
|
+
Failed = 'failed',
|
|
13
|
+
Cancelled = 'cancelled',
|
|
14
|
+
TimedOut = 'timed-out',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum TaskPriorityEnum {
|
|
18
|
+
Lowest = 'lowest',
|
|
19
|
+
Low = 'low',
|
|
20
|
+
Normal = 'normal',
|
|
21
|
+
High = 'high',
|
|
22
|
+
Highest = 'highest',
|
|
23
|
+
}
|
package/source/framework/env.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {GenericValueType} from "../types/generic";
|
|
2
|
-
import {getType} from "./utilities";
|
|
1
|
+
import {GenericValueType} from "../types/generic.ts";
|
|
2
|
+
import {getType} from "./utilities/index.ts";
|
|
3
3
|
|
|
4
4
|
export function env<T>(key: string, defaultValue?: T, type?: GenericValueType): T | undefined {
|
|
5
5
|
const value = process.env[key] || defaultValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpStatus} from "../enums/http-status.enum";
|
|
2
|
-
import {Raiton} from "../../core";
|
|
3
|
-
import {HttpResponseBaseInterface} from "../../types";
|
|
1
|
+
import {HttpStatus} from "../enums/http-status.enum.ts";
|
|
2
|
+
import {Raiton} from "../../core/index.ts";
|
|
3
|
+
import {HttpResponseBaseInterface} from "../../types/index.ts";
|
|
4
4
|
|
|
5
5
|
export class HttpException extends Error {
|
|
6
6
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./http-exception"
|
|
2
|
-
export * from "./throwable"
|
|
1
|
+
export * from "./http-exception.ts"
|
|
2
|
+
export * from "./throwable.ts"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {HttpStatus, HttpMethod} from "./enums";
|
|
2
|
-
import {RaitonResponses} from "./responses/helpers";
|
|
3
|
-
import {ApplicationInterface} from "../types/application";
|
|
4
|
-
import {RequestContext} from "../core/context";
|
|
1
|
+
import {HttpStatus, HttpMethod} from "./enums/index.ts";
|
|
2
|
+
import {RaitonResponses} from "./responses/helpers.ts";
|
|
3
|
+
import {ApplicationInterface} from "../types/application.ts";
|
|
4
|
+
import {RequestContext} from "../core/context.ts";
|
|
5
5
|
|
|
6
6
|
export interface HealthCheckConfig {
|
|
7
7
|
enabled: boolean;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
export * from "./enums/index"
|
|
2
|
-
export * from "./constants/index"
|
|
3
|
-
export * from "./utilities/index"
|
|
4
|
-
export * from "./responses/index"
|
|
5
|
-
export * from "./decorators/index"
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./
|
|
17
|
-
export * from "./
|
|
1
|
+
export * from "./enums/index.ts"
|
|
2
|
+
export * from "./constants/index.ts"
|
|
3
|
+
export * from "./utilities/index.ts"
|
|
4
|
+
export * from "./responses/index.ts"
|
|
5
|
+
export * from "./decorators/index.ts"
|
|
6
|
+
export * from "./cache/index.ts"
|
|
7
|
+
export * from "./plugins/index.ts"
|
|
8
|
+
export * from "./runtime/index.ts"
|
|
9
|
+
export * from "./mcp/index.ts"
|
|
10
|
+
export * from "./exceptions/index.ts"
|
|
11
|
+
export * from "./health-check.ts"
|
|
12
|
+
export * from "./controllers.ts"
|
|
13
|
+
export * from "./data-transfer-object.ts"
|
|
14
|
+
export * from "./view-model.ts"
|
|
15
|
+
export * from "./encryption.ts"
|
|
16
|
+
export * from "./parameter-bag.ts"
|
|
17
|
+
export * from "./repositories.ts"
|
|
18
|
+
export * from "./services.ts"
|
|
@@ -4,15 +4,15 @@ import type {
|
|
|
4
4
|
McpElementMetaInterface,
|
|
5
5
|
McpServerRegistrationInterface,
|
|
6
6
|
McpToolResultContent,
|
|
7
|
-
} from "../../types";
|
|
7
|
+
} from "../../types/index.ts";
|
|
8
8
|
import {
|
|
9
9
|
JsonRpcErrorCode,
|
|
10
10
|
LatestProtocolVersion,
|
|
11
11
|
rpcError,
|
|
12
12
|
rpcFailure,
|
|
13
13
|
rpcSuccess,
|
|
14
|
-
} from "./protocol";
|
|
15
|
-
import {Injection} from "../../core/injection";
|
|
14
|
+
} from "./protocol.ts";
|
|
15
|
+
import {Injection} from "../../core/injection/index.ts";
|
|
16
16
|
|
|
17
17
|
export interface McpHandleResult {
|
|
18
18
|
kind: 'response' | 'notification';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./protocol"
|
|
2
|
-
export * from "./handler"
|
|
3
|
-
export * from "./streamable-http"
|
|
1
|
+
export * from "./protocol.ts"
|
|
2
|
+
export * from "./handler.ts"
|
|
3
|
+
export * from "./streamable-http.ts"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
McpServerRegistrationInterface,
|
|
3
|
-
} from "../../types";
|
|
4
|
-
import {McpVersion} from "./protocol";
|
|
5
|
-
import {handleMcpRequest} from "./handler";
|
|
3
|
+
} from "../../types/index.ts";
|
|
4
|
+
import {McpVersion} from "./protocol.ts";
|
|
5
|
+
import {handleMcpRequest} from "./handler.ts";
|
|
6
6
|
|
|
7
7
|
export const SESSION_HEADER = 'mcp-session-id'
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ParseableEntriesType, ParseablePrimitiveType} from "../types";
|
|
2
|
-
import {stabilizeJson} from "./utilities";
|
|
1
|
+
import {ParseableEntriesType, ParseablePrimitiveType} from "../types/index.ts";
|
|
2
|
+
import {stabilizeJson} from "./utilities/index.ts";
|
|
3
3
|
import {DynamicParameter, IDynamicParameters, IDynamicProps, IParameter,} from "@protorians/parameters";
|
|
4
4
|
|
|
5
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {MiddlewareParametersInterface, PluginInterface} from "../../types";
|
|
2
|
-
import {RequestContext} from "../../core/context";
|
|
1
|
+
import type {MiddlewareParametersInterface, PluginInterface} from "../../types/index.ts";
|
|
2
|
+
import {RequestContext} from "../../core/context.ts";
|
|
3
3
|
import {Logger} from "@protorians/logger";
|
|
4
|
-
import {tryParseJson} from "../utilities/json.util";
|
|
4
|
+
import {tryParseJson} from "../utilities/json.util.ts";
|
|
5
5
|
|
|
6
6
|
export function bodyParserPlugin(): PluginInterface {
|
|
7
7
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./body-parser.plugin";
|
|
2
|
-
export * from "./security/index";
|
|
3
|
-
export * from "./openapi.plugin";
|
|
4
|
-
export * from "./mcp.plugin";
|
|
1
|
+
export * from "./body-parser.plugin.ts";
|
|
2
|
+
export * from "./security/index.ts";
|
|
3
|
+
export * from "./openapi.plugin.ts";
|
|
4
|
+
export * from "./mcp.plugin.ts";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {PluginInterface} from "../../types";
|
|
2
|
-
import type {ContextInterface} from "../../types/core";
|
|
3
|
-
import {PluginScope} from "../../core";
|
|
4
|
-
import {findMcpServerForPath} from "../../core/mcp/metadata";
|
|
5
|
-
import {isMcpJsonRpc, mcpHandleGet, mcpHandlePost, SESSION_HEADER} from "../mcp/streamable-http";
|
|
1
|
+
import type {PluginInterface} from "../../types/index.ts";
|
|
2
|
+
import type {ContextInterface} from "../../types/core.ts";
|
|
3
|
+
import {PluginScope} from "../../core/index.ts";
|
|
4
|
+
import {findMcpServerForPath} from "../../core/mcp/metadata.ts";
|
|
5
|
+
import {isMcpJsonRpc, mcpHandleGet, mcpHandlePost, SESSION_HEADER} from "../mcp/streamable-http.ts";
|
|
6
6
|
|
|
7
7
|
export interface McpPluginOptions {
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {PluginInterface} from "../../types";
|
|
2
|
-
import type {ContextInterface} from "../../types/core";
|
|
3
|
-
import {PluginScope} from "../../core";
|
|
1
|
+
import type {PluginInterface} from "../../types/index.ts";
|
|
2
|
+
import type {ContextInterface} from "../../types/core.ts";
|
|
3
|
+
import {PluginScope} from "../../core/index.ts";
|
|
4
4
|
import {Logger} from "@protorians/logger";
|
|
5
|
-
import {generateOpenApiSpec} from "../utilities/openapi.utils";
|
|
5
|
+
import {generateOpenApiSpec} from "../utilities/openapi.utils.ts";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* OpenAPI plugin options
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {definePlugin} from "../../../core/plugins";
|
|
2
|
-
import {MiddlewareParametersInterface} from "../../../types";
|
|
3
|
-
import {RaitonResponses, HttpStatus} from "
|
|
1
|
+
import {definePlugin} from "../../../core/plugins/index.ts";
|
|
2
|
+
import {MiddlewareParametersInterface} from "../../../types/index.ts";
|
|
3
|
+
import {RaitonResponses, HttpStatus} from "../../index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export const secureBodyLimit = (maxBytes = 1_000_000) =>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {definePlugin} from "../../../core/plugins";
|
|
2
|
-
import {MiddlewareParametersInterface} from "../../../types";
|
|
1
|
+
import {definePlugin} from "../../../core/plugins/index.ts";
|
|
2
|
+
import {MiddlewareParametersInterface} from "../../../types/index.ts";
|
|
3
3
|
import {Logger} from "@protorians/logger";
|
|
4
4
|
|
|
5
5
|
export interface CorsOptions {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
|
-
import {definePlugin} from "../../../core/plugins";
|
|
3
|
-
import {MiddlewareParametersInterface} from "../../../types";
|
|
4
|
-
import {RaitonResponses, HttpStatus} from "
|
|
5
|
-
import {CsrfUtil} from "../../utilities/csrf.util";
|
|
6
|
-
import {CSRFModeEnum} from "../../enums";
|
|
7
|
-
import type {CsrfOptions, CsrfCookieOptions} from "../../../types";
|
|
2
|
+
import {definePlugin} from "../../../core/plugins/index.ts";
|
|
3
|
+
import {MiddlewareParametersInterface} from "../../../types/index.ts";
|
|
4
|
+
import {RaitonResponses, HttpStatus} from "../../index.ts";
|
|
5
|
+
import {CsrfUtil} from "../../utilities/csrf.util.ts";
|
|
6
|
+
import {CSRFModeEnum} from "../../enums/index.ts";
|
|
7
|
+
import type {CsrfOptions, CsrfCookieOptions} from "../../../types/index.ts";
|
|
8
8
|
|
|
9
9
|
const DEFAULT_METHODS = ['POST', 'PUT', 'PATCH', 'DELETE']
|
|
10
10
|
const DEFAULT_COOKIE_NAME = '_csrf'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {definePlugin} from "../../../core/plugins";
|
|
2
|
-
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types";
|
|
1
|
+
import {definePlugin} from "../../../core/plugins/index.ts";
|
|
2
|
+
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types/index.ts";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const secureHeaders = definePlugin((scope) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {secureHeaders} from './headers'
|
|
2
|
-
import {secureCors} from './cors'
|
|
3
|
-
import {secureRateLimit} from './rate-limit'
|
|
4
|
-
import {secureBodyLimit} from './body-limit'
|
|
5
|
-
import {secureMethodGuard} from './method-guard'
|
|
6
|
-
import {secureCsrf} from './csrf'
|
|
1
|
+
import {secureHeaders} from './headers.ts'
|
|
2
|
+
import {secureCors} from './cors.ts'
|
|
3
|
+
import {secureRateLimit} from './rate-limit.ts'
|
|
4
|
+
import {secureBodyLimit} from './body-limit.ts'
|
|
5
|
+
import {secureMethodGuard} from './method-guard.ts'
|
|
6
|
+
import {secureCsrf} from './csrf.ts'
|
|
7
7
|
|
|
8
8
|
export class Security {
|
|
9
9
|
static headers = secureHeaders
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {definePlugin} from "../../../core/plugins";
|
|
2
|
-
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types";
|
|
3
|
-
import {RaitonResponses, HttpStatus} from "
|
|
1
|
+
import {definePlugin} from "../../../core/plugins/index.ts";
|
|
2
|
+
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types/index.ts";
|
|
3
|
+
import {RaitonResponses, HttpStatus} from "../../index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export const secureMethodGuard = (allowed: string[]) =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {definePlugin} from "../../../core/plugins";
|
|
2
|
-
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types";
|
|
3
|
-
import {RaitonResponses, HttpStatus} from "
|
|
1
|
+
import {definePlugin} from "../../../core/plugins/index.ts";
|
|
2
|
+
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types/index.ts";
|
|
3
|
+
import {RaitonResponses, HttpStatus} from "../../index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export interface RateLimitOptions {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpResponse, HttpStatus} from "
|
|
2
|
-
import {HttpResponseInterface} from "../../types";
|
|
3
|
-
import {Raiton} from "../../core";
|
|
1
|
+
import {HttpResponse, HttpStatus} from "../index.ts";
|
|
2
|
+
import {HttpResponseInterface} from "../../types/index.ts";
|
|
3
|
+
import {Raiton} from "../../core/index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export function RaitonResponses(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpResponseInterface} from "../../types";
|
|
2
|
-
import {HttpStatus} from "../enums";
|
|
3
|
-
import {Raiton} from "../../core";
|
|
1
|
+
import {HttpResponseInterface} from "../../types/index.ts";
|
|
2
|
+
import {HttpStatus} from "../enums/index.ts";
|
|
3
|
+
import {Raiton} from "../../core/index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export class ThrowableResponse extends Error {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpResponseInterface} from "../../types";
|
|
2
|
-
import {HttpStatus} from "../enums";
|
|
3
|
-
import {ThrowableResponse} from ".";
|
|
1
|
+
import {HttpResponseInterface} from "../../types/index.ts";
|
|
2
|
+
import {HttpStatus} from "../enums/index.ts";
|
|
3
|
+
import {ThrowableResponse} from "./index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export class HttpResponse {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./error"
|
|
2
|
-
export * from "./http-throwable"
|
|
3
|
-
export * from "./http"
|
|
4
|
-
export * from "./helpers"
|
|
1
|
+
export * from "./error.ts"
|
|
2
|
+
export * from "./http-throwable.ts"
|
|
3
|
+
export * from "./http.ts"
|
|
4
|
+
export * from "./helpers.ts"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RuntimeAdapterInterface,
|
|
3
3
|
RuntimeServerOptionsInterface,
|
|
4
|
-
} from '../../../types'
|
|
4
|
+
} from '../../../types/index.ts'
|
|
5
5
|
import {Logger} from "@protorians/logger";
|
|
6
|
-
import {getRealIp} from "../../utilities";
|
|
7
|
-
import {findSocketForPath} from "../../../core/socket";
|
|
8
|
-
import {Injection} from "../../../core/injection";
|
|
9
|
-
import {RaitonResponses, HttpStatus} from "
|
|
6
|
+
import {getRealIp} from "../../utilities/index.ts";
|
|
7
|
+
import {findSocketForPath} from "../../../core/socket/index.ts";
|
|
8
|
+
import {Injection} from "../../../core/injection/index.ts";
|
|
9
|
+
import {RaitonResponses, HttpStatus} from "../../index.ts";
|
|
10
10
|
|
|
11
11
|
export const bunRuntime: RuntimeAdapterInterface = {
|
|
12
12
|
createServer(handler, options?: RuntimeServerOptionsInterface) {
|