raiton 3.1.1 → 5.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +38 -3
- package/build/bin/index.mjs +822 -524
- package/examples/user-controller.example.ts +53 -0
- package/package.json +8 -10
- package/scripts/update-version.ts +1 -1
- package/source/bin/bootstrapper.ts +1 -1
- package/source/bin/cli-tools.ts +2 -0
- package/source/commands/build.command.ts +2 -1
- package/source/commands/develop.command.ts +2 -1
- package/source/commands/start.command.ts +15 -10
- package/source/core/application.ts +42 -33
- package/source/core/artifacts/artifact.ts +10 -0
- package/source/core/artifacts/index.ts +1 -0
- package/source/core/artifacts/runner.ts +3 -0
- package/source/core/builder.ts +44 -15
- 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/hooks.ts +0 -8
- package/source/core/index.ts +15 -14
- package/source/core/injection/injection.ts +9 -6
- package/source/core/middleware/compose.ts +1 -1
- package/source/core/middleware/pipeline.ts +2 -8
- package/source/core/plugins/scope.ts +18 -6
- package/source/core/router/handler.ts +26 -80
- package/source/core/router/handler.utils.ts +135 -0
- package/source/core/router/matcher.ts +13 -9
- package/source/core/router/router.ts +6 -2
- package/source/core/socket/index.ts +1 -0
- package/source/core/socket/metadata.ts +13 -0
- package/source/core/thread.ts +23 -20
- package/source/{sdk → framework}/artifacts.ts +8 -1
- package/source/framework/constants/decorators.constant.ts +17 -0
- package/source/framework/decorators/api-response.decorator.ts +127 -0
- package/source/framework/decorators/api.decorator.ts +185 -0
- package/source/framework/decorators/index.ts +9 -0
- package/source/{sdk/decorators/parametrable.ts → framework/decorators/parametrable.decorator.ts} +1 -1
- package/source/framework/decorators/socket.decorator.ts +41 -0
- package/source/{sdk → framework}/encryption.ts +2 -1
- package/source/{sdk → framework}/enums/encrypted.enum.ts +2 -2
- package/source/{sdk → framework}/enums/http-parameters.enum.ts +1 -0
- package/source/{sdk → framework}/enums/runtime.enum.ts +2 -2
- package/source/{sdk → framework}/env.ts +2 -2
- package/source/{sdk → framework}/exceptions/http-exception.ts +1 -1
- package/source/{sdk → framework}/index.ts +3 -2
- package/source/{sdk → framework}/plugins/body-parser.plugin.ts +28 -11
- package/source/framework/plugins/index.ts +3 -0
- package/source/framework/plugins/openapi.plugin.ts +98 -0
- package/source/framework/plugins/security/cors.ts +78 -0
- package/source/{sdk → framework}/responses/helpers.ts +4 -3
- package/source/{sdk → framework}/responses/http-throwable.ts +2 -2
- package/source/{sdk → framework}/responses/http.ts +3 -3
- package/source/{sdk → framework}/runtime/bun/server.ts +6 -2
- package/source/framework/runtime/deno/server.ts +104 -0
- package/source/{sdk → framework}/runtime/index.ts +18 -13
- package/source/framework/runtime/node/reply.ts +37 -0
- package/source/framework/runtime/node/request.ts +47 -0
- package/source/framework/runtime/node/server.ts +32 -0
- package/source/framework/runtime/web/server.ts +73 -0
- package/source/{sdk → framework}/utilities/artifact.util.ts +3 -0
- package/source/framework/utilities/cookie.util.ts +11 -0
- package/source/{sdk → framework}/utilities/index.ts +3 -1
- package/source/framework/utilities/openapi.utils.ts +497 -0
- package/source/framework/view-model.ts +4 -0
- package/source/types/access-guards.ts +4 -0
- package/source/types/application.ts +1 -1
- package/source/types/artifact.ts +42 -1
- package/source/types/builder.ts +6 -1
- package/source/types/controller.ts +1 -1
- package/source/types/http-responses.ts +8 -0
- 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 +5 -3
- package/source/types/scheme.ts +153 -0
- package/source/types/socket.ts +15 -0
- package/source/types/thread.ts +4 -2
- package/source/sdk/constants/decorators.constant.ts +0 -8
- package/source/sdk/decorators/index.ts +0 -6
- package/source/sdk/plugins/index.ts +0 -2
- package/source/sdk/plugins/security/cors.ts +0 -44
- package/source/sdk/runtime/deno/server.ts +0 -53
- package/source/sdk/runtime/node/reply.ts +0 -0
- package/source/sdk/runtime/node/request.ts +0 -0
- package/source/sdk/runtime/node/server.ts +0 -60
- package/source/sdk/runtime/web/server.ts +0 -57
- /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/routable.decorator.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-status.enum.ts +0 -0
- /package/source/{sdk → framework}/enums/index.ts +0 -0
- /package/source/{sdk → framework}/enums/timestamp.enum.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}/parameter-bag.ts +0 -0
- /package/source/{sdk → framework}/plugins/security/body-limit.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/index.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/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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {RuntimeAdapterInterface} from '../../../types'
|
|
2
|
+
import {Logger} from "@protorians/logger";
|
|
2
3
|
|
|
3
4
|
export const bunRuntime: RuntimeAdapterInterface = {
|
|
4
5
|
createServer(handler) {
|
|
@@ -23,7 +24,7 @@ export const bunRuntime: RuntimeAdapterInterface = {
|
|
|
23
24
|
method: request.method,
|
|
24
25
|
url: request.url,
|
|
25
26
|
headers: request.headers as any,
|
|
26
|
-
body: request.body
|
|
27
|
+
body: request.body ? request.body : null
|
|
27
28
|
},
|
|
28
29
|
{
|
|
29
30
|
status(code) {
|
|
@@ -49,6 +50,9 @@ export const bunRuntime: RuntimeAdapterInterface = {
|
|
|
49
50
|
headers.set('content-type', 'application/json')
|
|
50
51
|
responseBody = JSON.stringify(json)
|
|
51
52
|
},
|
|
53
|
+
type(contentType: string) {
|
|
54
|
+
headers.set('content-type', contentType)
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
)
|
|
54
58
|
|
|
@@ -70,4 +74,4 @@ export const bunRuntime: RuntimeAdapterInterface = {
|
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
|
-
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {RuntimeAdapterInterface, RuntimeRequestInterface, RuntimeReplyInterface} from '../../../types'
|
|
2
|
+
import {Logger} from "@protorians/logger";
|
|
3
|
+
|
|
4
|
+
// class DenoRequest implements RuntimeRequestInterface {
|
|
5
|
+
// constructor(private req: Request) {}
|
|
6
|
+
// get method(): string { return this.req.method; }
|
|
7
|
+
// get url(): string { return this.req.url; }
|
|
8
|
+
// get headers(): Headers { return new Headers(this.req.headers); }
|
|
9
|
+
// get body(): any { return this.req.body; }
|
|
10
|
+
// get query(): Record<string, any> | undefined { return undefined; }
|
|
11
|
+
// get params(): Record<string, any> | undefined { return undefined; }
|
|
12
|
+
// get file(): any { return undefined; }
|
|
13
|
+
// get files(): any { return undefined; }
|
|
14
|
+
// get remoteAddress(): string | undefined { return undefined; }
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
// class DenoReply implements RuntimeReplyInterface {
|
|
18
|
+
// private statusCode: number = 200;
|
|
19
|
+
// private headers: Headers = new Headers();
|
|
20
|
+
// private body: BodyInit | null = null;
|
|
21
|
+
//
|
|
22
|
+
// status(code: number): void { this.statusCode = code; }
|
|
23
|
+
// header(name: string, value: string): void { this.headers.set(name, value); }
|
|
24
|
+
// send(body: any): void {
|
|
25
|
+
// if (body === undefined) {
|
|
26
|
+
// this.body = null;
|
|
27
|
+
// } else if (typeof body === 'string' || body instanceof Uint8Array) {
|
|
28
|
+
// this.body = body;
|
|
29
|
+
// } else {
|
|
30
|
+
// if (!this.headers.has('content-type')) {
|
|
31
|
+
// this.headers.set('content-type', 'application/json');
|
|
32
|
+
// }
|
|
33
|
+
// this.body = JSON.stringify(body);
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
// text(text: string | Buffer): void {
|
|
37
|
+
// // Accept string, Uint8Array, or any other value (including Buffer-like)
|
|
38
|
+
// if (typeof text === 'string' || text instanceof Uint8Array) {
|
|
39
|
+
// this.body = text;
|
|
40
|
+
// } else {
|
|
41
|
+
// // Fallback: treat as JSON string
|
|
42
|
+
// this.body = JSON.stringify(text);
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
// json(json: any): void {
|
|
46
|
+
// this.headers.set('content-type', 'application/json');
|
|
47
|
+
// this.body = JSON.stringify(json);
|
|
48
|
+
// }
|
|
49
|
+
// type(contentType: string): void {
|
|
50
|
+
// this.headers.set('content-type', contentType);
|
|
51
|
+
// }
|
|
52
|
+
// toResponse(): Response {
|
|
53
|
+
// let bodyToSend: BodyInit = '';
|
|
54
|
+
// if (this.body instanceof Uint8Array) {
|
|
55
|
+
// bodyToSend = this.body;
|
|
56
|
+
// } else if (typeof this.body === 'string') {
|
|
57
|
+
// bodyToSend = this.body;
|
|
58
|
+
// } else if (this.body === null) {
|
|
59
|
+
// bodyToSend = '';
|
|
60
|
+
// } else {
|
|
61
|
+
// // fallback: treat as JSON
|
|
62
|
+
// bodyToSend = JSON.stringify(this.body);
|
|
63
|
+
// }
|
|
64
|
+
// return new Response(bodyToSend, { status: this.statusCode, headers: this.headers });
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @alpha Not ready
|
|
70
|
+
*/
|
|
71
|
+
export const denoRuntime: RuntimeAdapterInterface = {
|
|
72
|
+
createServer(handler) {
|
|
73
|
+
let controller: AbortController | null = null;
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
async listen(port, hostname) {
|
|
77
|
+
// controller = new AbortController();
|
|
78
|
+
//
|
|
79
|
+
// const server = Deno.serve({
|
|
80
|
+
// port: Number(port),
|
|
81
|
+
// hostname,
|
|
82
|
+
// signal: controller.signal,
|
|
83
|
+
// handler: async (reqEvent) => {
|
|
84
|
+
// const denoReq = new DenoRequest(reqEvent.request);
|
|
85
|
+
// const denoRes = new DenoReply();
|
|
86
|
+
//
|
|
87
|
+
// await handler(denoReq, denoRes);
|
|
88
|
+
//
|
|
89
|
+
// const resp = denoRes.toResponse();
|
|
90
|
+
// await reqEvent.respondWith(resp);
|
|
91
|
+
// }
|
|
92
|
+
// });
|
|
93
|
+
|
|
94
|
+
// Server will run until close() is called
|
|
95
|
+
},
|
|
96
|
+
async close() {
|
|
97
|
+
// if (controller) {
|
|
98
|
+
// controller.abort();
|
|
99
|
+
// }
|
|
100
|
+
// Note: Deno.serve does not expose a direct stop; closing the signal aborts incoming connections.
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
RuntimeAdapterInterface,
|
|
3
|
+
RuntimeHandlerCallable,
|
|
4
|
+
RuntimeInterface,
|
|
5
|
+
RuntimeServerInterface
|
|
6
|
+
} from "../../types";
|
|
2
7
|
import {RuntimeType} from "../enums/runtime.enum";
|
|
3
8
|
import {nodeRuntime} from "./node/server";
|
|
4
9
|
import {bunRuntime} from "./bun/server";
|
|
5
10
|
import {denoRuntime} from "./deno/server";
|
|
6
|
-
import {webRuntime} from "./web/server";
|
|
11
|
+
// import {webRuntime} from "./web/server";
|
|
7
12
|
|
|
8
13
|
|
|
9
14
|
export class Runtime implements RuntimeInterface {
|
|
@@ -16,13 +21,13 @@ export class Runtime implements RuntimeInterface {
|
|
|
16
21
|
return this.type === RuntimeType.Node;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
get isDeno(): boolean {
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get isWeb(): boolean {
|
|
24
|
-
|
|
25
|
-
}
|
|
24
|
+
// get isDeno(): boolean {
|
|
25
|
+
// return this.type === RuntimeType.Deno;
|
|
26
|
+
// }
|
|
27
|
+
//
|
|
28
|
+
// get isWeb(): boolean {
|
|
29
|
+
// return this.type === RuntimeType.Web;
|
|
30
|
+
// }
|
|
26
31
|
|
|
27
32
|
get isBun(): boolean {
|
|
28
33
|
return this.type === RuntimeType.Bun;
|
|
@@ -34,10 +39,10 @@ export class Runtime implements RuntimeInterface {
|
|
|
34
39
|
return nodeRuntime
|
|
35
40
|
case RuntimeType.Bun:
|
|
36
41
|
return bunRuntime
|
|
37
|
-
case RuntimeType.Deno:
|
|
38
|
-
|
|
39
|
-
case RuntimeType.Web:
|
|
40
|
-
|
|
42
|
+
// case RuntimeType.Deno:
|
|
43
|
+
// return denoRuntime
|
|
44
|
+
// case RuntimeType.Web:
|
|
45
|
+
// return webRuntime
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ServerResponse } from 'node:http'
|
|
2
|
+
import type { RuntimeReplyInterface } from '../../../types'
|
|
3
|
+
|
|
4
|
+
export class NodeReply implements RuntimeReplyInterface {
|
|
5
|
+
constructor(public res: ServerResponse) {}
|
|
6
|
+
|
|
7
|
+
status(code: number): void {
|
|
8
|
+
this.res.statusCode = code
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
header(name: string, value: string): void {
|
|
12
|
+
this.res.setHeader(name, value)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
send(body: any): void {
|
|
16
|
+
if (body === undefined) {
|
|
17
|
+
this.res.end()
|
|
18
|
+
} else if (typeof body === 'string' || Buffer.isBuffer(body)) {
|
|
19
|
+
this.res.end(body)
|
|
20
|
+
} else {
|
|
21
|
+
this.res.setHeader('content-type', 'application/json')
|
|
22
|
+
this.res.end(JSON.stringify(body))
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
text(text: string | Buffer): void {
|
|
27
|
+
this.res.end(text)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
json(json: any): void {
|
|
31
|
+
this.res.end(JSON.stringify(json))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type(contentType: string): void {
|
|
35
|
+
this.res.setHeader('content-type', contentType)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IncomingMessage } from 'node:http'
|
|
2
|
+
import type { RuntimeRequestInterface } from '../../../types'
|
|
3
|
+
|
|
4
|
+
export class NodeRequest implements RuntimeRequestInterface {
|
|
5
|
+
constructor(public req: IncomingMessage) {
|
|
6
|
+
// copy or wrap
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
get method(): string {
|
|
10
|
+
return this.req.method ?? 'GET'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get url(): string {
|
|
14
|
+
return this.req.url ?? '/'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get headers(): Headers {
|
|
18
|
+
return new Headers(this.req.headers as Record<string, string>)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get body(): any {
|
|
22
|
+
// In Node, the request body is a stream; we leave it as the request object itself for simplicity
|
|
23
|
+
return this.req
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get query(): Record<string, any> | undefined {
|
|
27
|
+
// Not implemented; middleware can parse query string from url
|
|
28
|
+
return undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get params(): Record<string, any> | undefined {
|
|
32
|
+
// Not implemented; route params filled by router
|
|
33
|
+
return undefined
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get file(): any {
|
|
37
|
+
return undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get files(): any {
|
|
41
|
+
return undefined
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get remoteAddress(): string | undefined {
|
|
45
|
+
return this.req.socket?.remoteAddress
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import http from 'node:http'
|
|
2
|
+
import {
|
|
3
|
+
RuntimeAdapterInterface,
|
|
4
|
+
RuntimeRequestInterface,
|
|
5
|
+
RuntimeReplyInterface
|
|
6
|
+
} from '../../../types'
|
|
7
|
+
import { NodeRequest } from './request'
|
|
8
|
+
import { NodeReply } from './reply'
|
|
9
|
+
|
|
10
|
+
export const nodeRuntime: RuntimeAdapterInterface = {
|
|
11
|
+
createServer(handler) {
|
|
12
|
+
const server = http.createServer(async (req, res) => {
|
|
13
|
+
const runtimeReq: any = new NodeRequest(req)
|
|
14
|
+
const runtimeReply: RuntimeReplyInterface = new NodeReply(res)
|
|
15
|
+
|
|
16
|
+
await handler(runtimeReq, runtimeReply)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
listen(port, hostname) {
|
|
21
|
+
return new Promise((resolve) =>
|
|
22
|
+
server.listen(port, hostname, resolve)
|
|
23
|
+
)
|
|
24
|
+
},
|
|
25
|
+
close() {
|
|
26
|
+
return new Promise((resolve, reject) =>
|
|
27
|
+
server.close(err => err ? reject(err) : resolve())
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// import {RuntimeAdapterInterface} from '../../../types'
|
|
2
|
+
// import {Logger} from "@protorians/logger";
|
|
3
|
+
//
|
|
4
|
+
// export const webRuntime: RuntimeAdapterInterface = {
|
|
5
|
+
// createServer(handler) {
|
|
6
|
+
// let responseBody: any
|
|
7
|
+
// let statusCode = 200
|
|
8
|
+
// const headers = new Headers()
|
|
9
|
+
//
|
|
10
|
+
// const fetching = async (request: Request, handler: any) => {
|
|
11
|
+
// // Reset for each request
|
|
12
|
+
// responseBody = undefined
|
|
13
|
+
// statusCode = 200
|
|
14
|
+
// // headers.clear()
|
|
15
|
+
//
|
|
16
|
+
// await handler(
|
|
17
|
+
// {
|
|
18
|
+
// method: request.method,
|
|
19
|
+
// url: request.url,
|
|
20
|
+
// headers: request.headers,
|
|
21
|
+
// body: request.body ? request.body : null
|
|
22
|
+
// },
|
|
23
|
+
// {
|
|
24
|
+
// status(code) {
|
|
25
|
+
// statusCode = code
|
|
26
|
+
// },
|
|
27
|
+
// header(name, value) {
|
|
28
|
+
// headers.set(name, value)
|
|
29
|
+
// },
|
|
30
|
+
// send(body: any) {
|
|
31
|
+
// if (body === undefined) {
|
|
32
|
+
// responseBody = ''
|
|
33
|
+
// } else if (typeof body === 'string' || body instanceof Uint8Array) {
|
|
34
|
+
// responseBody = body
|
|
35
|
+
// } else {
|
|
36
|
+
// headers.set('content-type', 'application/json')
|
|
37
|
+
// responseBody = JSON.stringify(body)
|
|
38
|
+
// }
|
|
39
|
+
// },
|
|
40
|
+
// text(text: string | Buffer) {
|
|
41
|
+
// responseBody = text
|
|
42
|
+
// },
|
|
43
|
+
// json(json: any) {
|
|
44
|
+
// headers.set('content-type', 'application/json')
|
|
45
|
+
// responseBody = JSON.stringify(json)
|
|
46
|
+
// },
|
|
47
|
+
// type(contentType: string) {
|
|
48
|
+
// headers.set('content-type', contentType)
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
51
|
+
// )
|
|
52
|
+
//
|
|
53
|
+
// return new Response(
|
|
54
|
+
// typeof responseBody === 'object' && !(responseBody instanceof Uint8Array)
|
|
55
|
+
// ? JSON.stringify(responseBody)
|
|
56
|
+
// : responseBody,
|
|
57
|
+
// {status: statusCode, headers}
|
|
58
|
+
// )
|
|
59
|
+
// }
|
|
60
|
+
//
|
|
61
|
+
// return {
|
|
62
|
+
// async listen() {
|
|
63
|
+
// console.warn('Web runtime does not support listening')
|
|
64
|
+
// },
|
|
65
|
+
// async close() {
|
|
66
|
+
// console.warn('Web runtime does not support closing')
|
|
67
|
+
// },
|
|
68
|
+
// async handle(request: Request) {
|
|
69
|
+
// return fetching(request, handler)
|
|
70
|
+
// }
|
|
71
|
+
// }
|
|
72
|
+
// }
|
|
73
|
+
// }
|
|
@@ -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')
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function parseCookie(cookieHeader: string | null): Record<string, string> {
|
|
2
|
+
const cookies: Record<string, string> = {};
|
|
3
|
+
if (!cookieHeader) return cookies;
|
|
4
|
+
cookieHeader.split(';').forEach(part => {
|
|
5
|
+
const [key, ...valueParts] = part.trim().split('=');
|
|
6
|
+
if (key) {
|
|
7
|
+
cookies[key] = valueParts.join('=');
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
return cookies;
|
|
11
|
+
}
|