raiton 3.0.1 → 3.1.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/CHANGELOG.md +15 -15
- package/README.md +1 -1
- package/build/bin/index.mjs +240 -2
- package/package.json +3 -4
- package/scripts/update-version.ts +5 -5
- package/source/bin/bootstrapper.ts +3 -3
- package/source/bin/cli-tools.ts +1 -1
- package/source/bin/cli.ts +1 -1
- package/source/commands/artifact.command.ts +3 -3
- package/source/commands/build.command.ts +3 -3
- package/source/commands/develop.command.ts +3 -3
- package/source/commands/grafts.command.ts +1 -1
- package/source/commands/start.command.ts +3 -3
- package/source/core/application.ts +23 -18
- package/source/core/builder.ts +8 -8
- package/source/core/bytes.util.ts +2 -2
- package/source/core/config/config.ts +8 -8
- package/source/core/config/define.ts +4 -4
- package/source/core/context.ts +1 -1
- package/source/core/controller/builder.ts +6 -6
- package/source/core/controller/compiler.ts +5 -5
- package/source/core/controller/metadata.ts +2 -2
- package/source/core/directories.ts +1 -1
- package/source/core/guards.ts +43 -0
- package/source/core/hooks.ts +4 -4
- package/source/core/injection/injection.ts +8 -7
- package/source/core/middleware/compose.ts +2 -2
- package/source/core/middleware/pipeline.ts +2 -2
- package/source/core/plugins/plugin.ts +3 -3
- package/source/core/plugins/scope.ts +3 -3
- package/source/core/raiton.ts +2 -2
- package/source/core/router/handler.ts +7 -7
- package/source/core/router/matcher.ts +1 -1
- package/source/core/router/route.ts +3 -3
- package/source/core/router/router.ts +5 -5
- package/source/core/server.ts +3 -3
- package/source/core/thread.ts +14 -13
- package/source/sdk/artifacts.ts +5 -5
- package/source/sdk/decorators/controllable.decorator.ts +3 -3
- package/source/sdk/decorators/guard.decorator.ts +23 -0
- package/source/sdk/decorators/index.ts +2 -1
- package/source/sdk/decorators/injection.decorator.ts +4 -4
- package/source/sdk/decorators/middleware.decorator.ts +2 -2
- package/source/sdk/decorators/parametrable.ts +3 -3
- package/source/sdk/decorators/routable.decorator.ts +3 -3
- package/source/sdk/encryption.ts +15 -15
- package/source/sdk/env.ts +5 -5
- package/source/sdk/exceptions/http-exception.ts +3 -3
- package/source/sdk/parameter-bag.ts +1 -1
- package/source/sdk/plugins/body-parser.plugin.ts +5 -5
- package/source/sdk/plugins/security/body-limit.ts +3 -3
- package/source/sdk/plugins/security/cors.ts +3 -3
- package/source/sdk/plugins/security/headers.ts +3 -3
- package/source/sdk/plugins/security/method-guard.ts +3 -3
- package/source/sdk/plugins/security/rate-limit.ts +3 -3
- package/source/sdk/repositories.ts +1 -1
- package/source/sdk/responses/error.ts +2 -2
- package/source/sdk/responses/helpers.ts +3 -3
- package/source/sdk/responses/http-throwable.ts +3 -3
- package/source/sdk/responses/http.ts +3 -3
- package/source/sdk/runtime/bun/server.ts +1 -1
- package/source/sdk/runtime/deno/server.ts +1 -1
- package/source/sdk/runtime/index.ts +6 -6
- package/source/sdk/runtime/node/server.ts +1 -1
- package/source/sdk/runtime/web/server.ts +1 -1
- package/source/sdk/utilities/utilities.util.ts +2 -2
- package/source/types/application.ts +5 -5
- package/source/types/artifact.ts +2 -43
- package/source/types/builder.ts +5 -5
- package/source/types/config.ts +3 -3
- package/source/types/controller.ts +6 -6
- package/source/types/contruct.ts +1 -1
- package/source/types/core.ts +3 -5
- package/source/types/directory.ts +1 -1
- package/source/types/encryption.ts +21 -12
- package/source/types/generic.ts +2 -2
- package/source/types/guard.ts +12 -0
- package/source/types/index.ts +1 -3
- package/source/types/injection.ts +2 -2
- package/source/types/lifecycle.ts +3 -3
- package/source/types/middleware.ts +5 -5
- package/source/types/plugin.ts +4 -6
- package/source/types/raiton.ts +3 -3
- package/source/types/responses.ts +10 -7
- package/source/types/router.ts +5 -5
- package/source/types/runtime.ts +1 -1
- package/source/types/server.ts +3 -3
- package/source/types/thread.ts +7 -7
- package/source/types/utilities.ts +1 -1
- package/source/types/values.ts +2 -2
- package/source/types/access-guards.ts +0 -4
- package/source/types/http-responses.ts +0 -8
- package/source/types/scheme.ts +0 -153
package/source/sdk/encryption.ts
CHANGED
|
@@ -2,7 +2,7 @@ import crypto from "node:crypto";
|
|
|
2
2
|
import argon2, {Options} from "argon2";
|
|
3
3
|
import {HashAlgoEnum, PasswordAlgoEnum} from "./enums";
|
|
4
4
|
import bcrypt from "bcrypt";
|
|
5
|
-
import {
|
|
5
|
+
import {DerivationOptionsInterface, EncryptionResultType, ScryptOptionsInterface} from "../types";
|
|
6
6
|
|
|
7
7
|
export class Encryption {
|
|
8
8
|
static get algos() {
|
|
@@ -24,7 +24,7 @@ export class Encryption {
|
|
|
24
24
|
return this.make(value).then(result => result === hash);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
async make(value: string, options?:
|
|
27
|
+
async make(value: string, options?: DerivationOptionsInterface | ScryptOptionsInterface): Promise<EncryptionResultType> {
|
|
28
28
|
if (!value) {
|
|
29
29
|
throw new Error('Value cannot be empty');
|
|
30
30
|
}
|
|
@@ -45,9 +45,9 @@ export class Encryption {
|
|
|
45
45
|
case HashAlgoEnum.SHA3_512:
|
|
46
46
|
return this.sha3_512(value);
|
|
47
47
|
case HashAlgoEnum.PBKDF2:
|
|
48
|
-
return this.pbkdf2(value, options as
|
|
48
|
+
return this.pbkdf2(value, options as DerivationOptionsInterface | undefined);
|
|
49
49
|
case HashAlgoEnum.SCRYPT:
|
|
50
|
-
return this.scrypt(value, options as
|
|
50
|
+
return this.scrypt(value, options as ScryptOptionsInterface | undefined);
|
|
51
51
|
case HashAlgoEnum.ARGON2ID:
|
|
52
52
|
case HashAlgoEnum.BCRYPT:
|
|
53
53
|
return this.password(value);
|
|
@@ -56,35 +56,35 @@ export class Encryption {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
protected sha256(value: string):
|
|
59
|
+
protected sha256(value: string): EncryptionResultType {
|
|
60
60
|
return crypto.createHash("sha256").update(value).digest("hex");
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
protected sha512(value: string):
|
|
63
|
+
protected sha512(value: string): EncryptionResultType {
|
|
64
64
|
return crypto.createHash("sha512").update(value).digest("hex");
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
protected md5(value: string):
|
|
67
|
+
protected md5(value: string): EncryptionResultType {
|
|
68
68
|
return crypto.createHash("md5").update(value).digest("hex");
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
protected ripemd160(value: string):
|
|
71
|
+
protected ripemd160(value: string): EncryptionResultType {
|
|
72
72
|
return crypto.createHash("ripemd160").update(value).digest("hex");
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
protected blake2b(value: string):
|
|
75
|
+
protected blake2b(value: string): EncryptionResultType {
|
|
76
76
|
return crypto.createHash("blake2b512").update(value).digest("hex");
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
protected sha3_256(value: string):
|
|
79
|
+
protected sha3_256(value: string): EncryptionResultType {
|
|
80
80
|
return crypto.createHash("sha3-256").update(value).digest("hex");
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
protected sha3_512(value: string):
|
|
83
|
+
protected sha3_512(value: string): EncryptionResultType {
|
|
84
84
|
return crypto.createHash("sha3-512").update(value).digest("hex");
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
protected pbkdf2(value: string, options?:
|
|
87
|
+
protected pbkdf2(value: string, options?: DerivationOptionsInterface): EncryptionResultType {
|
|
88
88
|
const {salt, iterations, keylen, digest} = options || {};
|
|
89
89
|
const usedSalt = salt ?? crypto.randomBytes(16).toString("hex");
|
|
90
90
|
const usedIterations = iterations ?? 100_000;
|
|
@@ -96,8 +96,8 @@ export class Encryption {
|
|
|
96
96
|
return `pbkdf2$${usedDigest}$${usedIterations}$${usedSalt}$${derived}`;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
protected scrypt(value: string, options?:
|
|
100
|
-
const {salt, keylen, cost, blockSize, parallelization} = options || {} as
|
|
99
|
+
protected scrypt(value: string, options?: ScryptOptionsInterface): EncryptionResultType {
|
|
100
|
+
const {salt, keylen, cost, blockSize, parallelization} = options || {} as ScryptOptionsInterface;
|
|
101
101
|
const usedSalt = salt ?? crypto.randomBytes(16).toString("hex");
|
|
102
102
|
const usedKeylen = keylen ?? 64;
|
|
103
103
|
const usedCost = cost ?? 16384; // N
|
|
@@ -120,7 +120,7 @@ export class Encryption {
|
|
|
120
120
|
|
|
121
121
|
async password(value: string, options?: (Options & {
|
|
122
122
|
raw?: boolean
|
|
123
|
-
}) | (string | number) | undefined): Promise<
|
|
123
|
+
}) | (string | number) | undefined): Promise<EncryptionResultType> {
|
|
124
124
|
switch (this.algo) {
|
|
125
125
|
case HashAlgoEnum.ARGON2ID: {
|
|
126
126
|
return await argon2.hash(value, {
|
package/source/sdk/env.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {GenericValueType} from "../types/generic";
|
|
2
2
|
import {getType} from "./utilities";
|
|
3
3
|
|
|
4
|
-
export function env<T>(key: string, type?:
|
|
4
|
+
export function env<T>(key: string, type?: GenericValueType): T | undefined {
|
|
5
5
|
const value = process.env[key];
|
|
6
|
-
type = type || getType(value) as
|
|
6
|
+
type = type || getType(value) as GenericValueType;
|
|
7
7
|
|
|
8
8
|
if (value) {
|
|
9
9
|
switch (type) {
|
|
@@ -28,10 +28,10 @@ export function env<T>(key: string, type?: IGenericValue): T | undefined {
|
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export function envGroup(key: string): Record<string,
|
|
31
|
+
export function envGroup(key: string): Record<string, GenericValueType | undefined> {
|
|
32
32
|
const filtered = Object.entries(process.env)
|
|
33
33
|
.filter(([index]) => key.startsWith(index))
|
|
34
|
-
const gen: Record<string,
|
|
34
|
+
const gen: Record<string, GenericValueType | undefined> = {}
|
|
35
35
|
|
|
36
36
|
for (const [index, value] of filtered)
|
|
37
37
|
gen[index] = env(value as any, undefined)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpStatus} from "
|
|
2
|
-
import {Raiton} from "
|
|
3
|
-
import {HttpResponseBaseInterface} from "
|
|
1
|
+
import {HttpStatus} from "../enums/http-status.enum";
|
|
2
|
+
import {Raiton} from "../../core";
|
|
3
|
+
import {HttpResponseBaseInterface} from "../../types";
|
|
4
4
|
|
|
5
5
|
export class HttpException extends Error {
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ParseableEntriesType, ParseablePrimitiveType} from "
|
|
1
|
+
import {ParseableEntriesType, ParseablePrimitiveType} from "../types";
|
|
2
2
|
import {stabilizeJson} from "./utilities";
|
|
3
3
|
import {DynamicParameter, IDynamicParameters, IDynamicProps, IParameter,} from "@protorians/parameters";
|
|
4
4
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {RequestContext} from "
|
|
1
|
+
import type {MiddlewareParametersInterface, PluginInterface} from "../../types";
|
|
2
|
+
import {RequestContext} from "../../core/context";
|
|
3
3
|
import {Logger} from "@protorians/logger";
|
|
4
|
-
import {tryParseJson} from "
|
|
4
|
+
import {tryParseJson} from "../utilities/json.util";
|
|
5
5
|
|
|
6
|
-
export function bodyParserPlugin():
|
|
6
|
+
export function bodyParserPlugin(): PluginInterface {
|
|
7
7
|
return {
|
|
8
8
|
name: 'body-parser-plugin',
|
|
9
9
|
setup: (scope) => {
|
|
10
|
-
scope.use(async ({context, next}:
|
|
10
|
+
scope.use(async ({context, next}: MiddlewareParametersInterface) => {
|
|
11
11
|
const contentType = context.req.headers.get('content-type') || '';
|
|
12
12
|
|
|
13
13
|
if (context.req.body && !context.state.bodyParsed) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {definePlugin} from "
|
|
2
|
-
import {
|
|
1
|
+
import {definePlugin} from "../../../core/plugins";
|
|
2
|
+
import {MiddlewareParametersInterface} from "../../../types";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const secureBodyLimit = (maxBytes = 1_000_000) =>
|
|
6
6
|
definePlugin((scope) => {
|
|
7
|
-
scope.use(async ({context, next}:
|
|
7
|
+
scope.use(async ({context, next}: MiddlewareParametersInterface) => {
|
|
8
8
|
const len = Number(
|
|
9
9
|
context.req.headers.get('content-length') ?? 0
|
|
10
10
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {definePlugin} from "
|
|
2
|
-
import {
|
|
1
|
+
import {definePlugin} from "../../../core/plugins";
|
|
2
|
+
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types";
|
|
3
3
|
|
|
4
4
|
export interface CorsOptions {
|
|
5
5
|
origin?: string | string[]
|
|
@@ -9,7 +9,7 @@ export interface CorsOptions {
|
|
|
9
9
|
|
|
10
10
|
export const secureCors = (opts: CorsOptions = {}) =>
|
|
11
11
|
definePlugin((scope) => {
|
|
12
|
-
scope.use(async ({context, next}:
|
|
12
|
+
scope.use(async ({context, next}: MiddlewareParametersInterface) => {
|
|
13
13
|
const origin = context.req.headers.get('origin')
|
|
14
14
|
|
|
15
15
|
if (opts.origin) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {definePlugin} from "
|
|
2
|
-
import {
|
|
1
|
+
import {definePlugin} from "../../../core/plugins";
|
|
2
|
+
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const secureHeaders = definePlugin((scope) => {
|
|
6
|
-
scope.use(async ({context, next}:
|
|
6
|
+
scope.use(async ({context, next}: MiddlewareParametersInterface) => {
|
|
7
7
|
context.reply.header('X-Content-Type-Options', 'nosniff')
|
|
8
8
|
context.reply.header('X-Frame-Options', 'DENY')
|
|
9
9
|
context.reply.header('Referrer-Policy', 'no-referrer')
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {definePlugin} from "
|
|
2
|
-
import {
|
|
1
|
+
import {definePlugin} from "../../../core/plugins";
|
|
2
|
+
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const secureMethodGuard = (allowed: string[]) =>
|
|
6
6
|
definePlugin((scope) => {
|
|
7
|
-
scope.use(async ({context, next}:
|
|
7
|
+
scope.use(async ({context, next}: MiddlewareParametersInterface) => {
|
|
8
8
|
if (!allowed.includes(context.req.method)) {
|
|
9
9
|
context.reply.status(405)
|
|
10
10
|
return context.send({ error: 'Method not allowed' })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {definePlugin} from "
|
|
2
|
-
import {
|
|
1
|
+
import {definePlugin} from "../../../core/plugins";
|
|
2
|
+
import {ContextInterface, MiddlewareParametersInterface, MiddlewareNextCallable} from "../../../types";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export interface RateLimitOptions {
|
|
@@ -16,7 +16,7 @@ export const secureRateLimit = (
|
|
|
16
16
|
const windowMs = opts.windowMs ?? 60_000
|
|
17
17
|
const max = opts.max ?? 100
|
|
18
18
|
|
|
19
|
-
scope.use(async ({context, next}:
|
|
19
|
+
scope.use(async ({context, next}: MiddlewareParametersInterface) => {
|
|
20
20
|
const ip =
|
|
21
21
|
context.req.remoteAddress ?? 'unknown'
|
|
22
22
|
const now = Date.now()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpResponse, HttpStatus} from "
|
|
2
|
-
import {HttpResponseInterface} from "
|
|
3
|
-
import {Raiton} from "
|
|
1
|
+
import {HttpResponse, HttpStatus} from "..";
|
|
2
|
+
import {HttpResponseInterface} from "../../types";
|
|
3
|
+
import {Raiton} from "../../core";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export function RaitonResponses(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpResponseInterface} from "
|
|
2
|
-
import {HttpStatus} from "
|
|
3
|
-
import {Raiton} from "
|
|
1
|
+
import {HttpResponseInterface} from "../../types";
|
|
2
|
+
import {HttpStatus} from "../enums";
|
|
3
|
+
import {Raiton} from "../../core";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export class ThrowableResponse extends Error {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpResponseInterface} from "
|
|
2
|
-
import {HttpStatus} from "
|
|
3
|
-
import {ThrowableResponse} from "
|
|
1
|
+
import {HttpResponseInterface} from "../../types";
|
|
2
|
+
import {HttpStatus} from "../enums";
|
|
3
|
+
import {ThrowableResponse} from ".";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export class HttpResponse {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {RuntimeAdapterInterface, RuntimeHandlerCallable, RuntimeInterface, RuntimeServerInterface} from "
|
|
2
|
-
import {RuntimeType} from "
|
|
3
|
-
import {nodeRuntime} from "
|
|
4
|
-
import {bunRuntime} from "
|
|
5
|
-
import {denoRuntime} from "
|
|
6
|
-
import {webRuntime} from "
|
|
1
|
+
import type {RuntimeAdapterInterface, RuntimeHandlerCallable, RuntimeInterface, RuntimeServerInterface} from "../../types";
|
|
2
|
+
import {RuntimeType} from "../enums/runtime.enum";
|
|
3
|
+
import {nodeRuntime} from "./node/server";
|
|
4
|
+
import {bunRuntime} from "./bun/server";
|
|
5
|
+
import {denoRuntime} from "./deno/server";
|
|
6
|
+
import {webRuntime} from "./web/server";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
export class Runtime implements RuntimeInterface {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {RuntimeAdapterInterface, RuntimeReplyInterface, RuntimeRequestInterface} from '
|
|
1
|
+
import {RuntimeAdapterInterface, RuntimeReplyInterface, RuntimeRequestInterface} from '../../../types'
|
|
2
2
|
|
|
3
3
|
export const webRuntime: RuntimeAdapterInterface = {
|
|
4
4
|
createServer(handler) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {GenericValuesType} from "../../types";
|
|
2
2
|
|
|
3
|
-
export function getType(value: any):
|
|
3
|
+
export function getType(value: any): GenericValuesType {
|
|
4
4
|
if (typeof value === "string") return "string";
|
|
5
5
|
if (typeof value === "boolean") return "boolean";
|
|
6
6
|
if (typeof value === "bigint") return "bigInt";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpMethod} from "
|
|
1
|
+
import {HttpMethod} from "../sdk";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface ApplicationConfigInterface {
|
|
4
4
|
workdir?: string;
|
|
5
5
|
hostname?: string;
|
|
6
6
|
port?: number;
|
|
@@ -12,13 +12,13 @@ export interface ApplicationConfig {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface ApplicationInterface {
|
|
15
|
-
readonly config:
|
|
15
|
+
readonly config: ApplicationConfigInterface;
|
|
16
16
|
|
|
17
17
|
get hostname(): string;
|
|
18
18
|
|
|
19
|
-
setOption<K extends keyof
|
|
19
|
+
setOption<K extends keyof ApplicationConfigInterface>(key: K, value: ApplicationConfigInterface[K]): this;
|
|
20
20
|
|
|
21
|
-
setOptions(options:
|
|
21
|
+
setOptions(options: ApplicationConfigInterface): this;
|
|
22
22
|
|
|
23
23
|
register(plugin: any): this;
|
|
24
24
|
|
package/source/types/artifact.ts
CHANGED
|
@@ -1,44 +1,3 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
id: string;
|
|
3
|
-
timestamp: Date;
|
|
4
|
-
size: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface ArtifactsConfig {
|
|
1
|
+
export interface ArtifactsConfigInterface {
|
|
8
2
|
types: string[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// export type ArtifactDecoratorHandler = () => void;
|
|
12
|
-
|
|
13
|
-
// export interface ArtifactDecorator {
|
|
14
|
-
// syntax: RegExp;
|
|
15
|
-
// handler: ArtifactDecoratorHandler;
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
// export interface ArtifactOptions {
|
|
19
|
-
// readonly artifact: string;
|
|
20
|
-
// readonly provider: string;
|
|
21
|
-
// readonly decorator: ArtifactDecorator;
|
|
22
|
-
// verbose?: boolean;
|
|
23
|
-
// }
|
|
24
|
-
|
|
25
|
-
// export interface ArtifactInterface {
|
|
26
|
-
// readonly options: ArtifactOptions;
|
|
27
|
-
// readonly directory: string;
|
|
28
|
-
// readonly file: string;
|
|
29
|
-
// readonly workdir: string;
|
|
30
|
-
//
|
|
31
|
-
// get files(): string[];
|
|
32
|
-
//
|
|
33
|
-
// get extensions(): string[];
|
|
34
|
-
//
|
|
35
|
-
// scan(): string[];
|
|
36
|
-
//
|
|
37
|
-
// generate(): boolean;
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
|
-
// export interface ArtifactEntry {
|
|
41
|
-
// vendor: string;
|
|
42
|
-
// decorator: string;
|
|
43
|
-
// pattern: string;
|
|
44
|
-
// }
|
|
3
|
+
}
|
package/source/types/builder.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {WatchEventType} from "node:fs";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface BuildCommandOptionsInterface {
|
|
4
4
|
develop?: boolean;
|
|
5
5
|
bootstrap?: boolean;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface BuilderConfigInterface {
|
|
9
9
|
development?: boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type BuilderBootCallableType = (builder: BuilderInterface) => Promise<void>
|
|
13
13
|
|
|
14
14
|
export interface BuilderInterface {
|
|
15
15
|
readonly workdir: string;
|
|
16
|
-
readonly options:
|
|
16
|
+
readonly options: BuilderConfigInterface;
|
|
17
17
|
// readonly signal: ISignalStack<BuilderSignalMap>;
|
|
18
18
|
|
|
19
19
|
// get context(): BuildContext<BuildOptions> | null;
|
|
@@ -36,7 +36,7 @@ export interface BuilderInterface {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
export interface
|
|
39
|
+
export interface BuilderHMRDeclarationInterface {
|
|
40
40
|
filename: string;
|
|
41
41
|
timestamp?: number;
|
|
42
42
|
version?: number;
|
package/source/types/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {ArtifactsConfigInterface} from "./artifact";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface ConfigurableInterface {
|
|
4
4
|
rootDir: string;
|
|
5
5
|
version: string;
|
|
6
|
-
artifacts?:
|
|
6
|
+
artifacts?: ArtifactsConfigInterface
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {HttpMethod, Parametrable} from "
|
|
2
|
-
import {
|
|
3
|
-
import {MiddlewareCallable, MiddlewareType} from "
|
|
1
|
+
import {HttpMethod, Parametrable} from "../sdk/enums";
|
|
2
|
+
import {ContextInterface} from "./core";
|
|
3
|
+
import {MiddlewareCallable, MiddlewareType} from "./middleware";
|
|
4
4
|
|
|
5
5
|
export interface ControllerMetaInterface {
|
|
6
6
|
prefix?: string;
|
|
@@ -20,14 +20,14 @@ export interface ParamMetaInterface {
|
|
|
20
20
|
index: number;
|
|
21
21
|
type: Parametrable;
|
|
22
22
|
key?: string;
|
|
23
|
-
callable?: (ctx:
|
|
23
|
+
callable?: (ctx: ContextInterface) => any;
|
|
24
24
|
metatype?: any;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export interface
|
|
27
|
+
export interface RouteDecoratorParametersInterface {
|
|
28
28
|
controller: ControllerMetaInterface;
|
|
29
29
|
route: RouteMetaInterface;
|
|
30
30
|
index: number;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export type RouteDecoratorCallable = (parameters:
|
|
33
|
+
export type RouteDecoratorCallable = (parameters: RouteDecoratorParametersInterface) => void;
|
package/source/types/contruct.ts
CHANGED
package/source/types/core.ts
CHANGED
|
@@ -3,18 +3,16 @@ import type {
|
|
|
3
3
|
RuntimeReplyInterface
|
|
4
4
|
} from './runtime'
|
|
5
5
|
|
|
6
|
-
export type
|
|
6
|
+
export type HookNameType =
|
|
7
7
|
| 'onRequest'
|
|
8
8
|
| 'preParsing'
|
|
9
9
|
| 'preHandler'
|
|
10
10
|
| 'onSend'
|
|
11
11
|
| 'onResponse'
|
|
12
12
|
|
|
13
|
-
export type
|
|
14
|
-
ctx: Context
|
|
15
|
-
) => Promise<void> | void
|
|
13
|
+
export type HookHandlerCallable = (ctx: ContextInterface) => Promise<void> | void
|
|
16
14
|
|
|
17
|
-
export interface
|
|
15
|
+
export interface ContextInterface {
|
|
18
16
|
req: RuntimeRequestInterface
|
|
19
17
|
reply: RuntimeReplyInterface
|
|
20
18
|
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
|
|
2
|
-
export type
|
|
2
|
+
export type EncryptionResultType = string;
|
|
3
3
|
|
|
4
|
-
export interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export interface DerivationOptionsInterface {
|
|
5
|
+
// hex string; if not provided, a random 16-byte salt will be generated
|
|
6
|
+
salt?: string;
|
|
7
|
+
// for PBKDF2
|
|
8
|
+
iterations?: number;
|
|
9
|
+
// bytes length for derived key (default 64)
|
|
10
|
+
keylen?: number;
|
|
11
|
+
// for PBKDF2 digest (default 'sha512')
|
|
12
|
+
digest?: string;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export interface
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export interface ScryptOptionsInterface {
|
|
16
|
+
// hex string; if not provided, a random 16-byte salt will be generated
|
|
17
|
+
salt?: string;
|
|
18
|
+
// bytes length for derived key (default 64)
|
|
19
|
+
keylen?: number;
|
|
20
|
+
// N parameter (default 16384)
|
|
21
|
+
cost?: number;
|
|
22
|
+
// r parameter (default 8)
|
|
23
|
+
blockSize?: number;
|
|
24
|
+
// p parameter (default 1)
|
|
25
|
+
parallelization?: number;
|
|
17
26
|
}
|
package/source/types/generic.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type GenericValueType = 'string' | 'int' | 'bigInt' | 'float' | 'boolean'
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type GenericValuesType = GenericValueType | 'array' | 'object' | 'function' | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {MiddlewareParametersInterface} from "./middleware";
|
|
2
|
+
|
|
3
|
+
export interface GuardOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
handler: GuardCallable
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface GuardDeclaration extends GuardOptions {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type GuardCallable = (parameters: MiddlewareParametersInterface) => Promise<boolean> | boolean
|
package/source/types/index.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export type * from "./config"
|
|
2
2
|
export type * from "./builder"
|
|
3
3
|
export type * from "./thread"
|
|
4
|
-
export type * from "./
|
|
4
|
+
export type * from "./guard"
|
|
5
5
|
export type * from "./contruct"
|
|
6
6
|
export type * from "./directory"
|
|
7
7
|
export type * from "./encryption"
|
|
8
8
|
export type * from "./generic"
|
|
9
|
-
export type * from "./http-responses"
|
|
10
9
|
export type * from "./parseable"
|
|
11
|
-
export type * from "./scheme"
|
|
12
10
|
export type * from "./values"
|
|
13
11
|
export type * from "./utilities"
|
|
14
12
|
export type * from "./artifact"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {ConstructorType} from "./contruct";
|
|
2
2
|
import {LifetimeEnum} from "@protorians/core";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export interface ContainerDefinitionInterface<T = any> {
|
|
6
6
|
name: string;
|
|
7
|
-
construct:
|
|
7
|
+
construct: ConstructorType<T>;
|
|
8
8
|
lifetime: LifetimeEnum;
|
|
9
9
|
instance?: any;
|
|
10
10
|
scope?: Symbol;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface OnMountInterface {
|
|
2
2
|
onMount(): void | Promise<void>;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface OnUnmountInterface {
|
|
6
6
|
onUnmount(): void | Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export interface
|
|
9
|
+
export interface OnInitInterface {
|
|
10
10
|
onInit(): void | Promise<void>;
|
|
11
11
|
}
|