@orchestr-sh/orchestr 1.0.1
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/LICENSE +21 -0
- package/README.md +344 -0
- package/dist/Container/Container.d.ts +90 -0
- package/dist/Container/Container.d.ts.map +1 -0
- package/dist/Container/Container.js +193 -0
- package/dist/Container/Container.js.map +1 -0
- package/dist/Facades/Route.d.ts +20 -0
- package/dist/Facades/Route.d.ts.map +1 -0
- package/dist/Facades/Route.js +50 -0
- package/dist/Facades/Route.js.map +1 -0
- package/dist/Foundation/Application.d.ts +97 -0
- package/dist/Foundation/Application.d.ts.map +1 -0
- package/dist/Foundation/Application.js +184 -0
- package/dist/Foundation/Application.js.map +1 -0
- package/dist/Foundation/Http/Kernel.d.ts +50 -0
- package/dist/Foundation/Http/Kernel.d.ts.map +1 -0
- package/dist/Foundation/Http/Kernel.js +122 -0
- package/dist/Foundation/Http/Kernel.js.map +1 -0
- package/dist/Foundation/ServiceProvider.d.ts +24 -0
- package/dist/Foundation/ServiceProvider.d.ts.map +1 -0
- package/dist/Foundation/ServiceProvider.js +15 -0
- package/dist/Foundation/ServiceProvider.js.map +1 -0
- package/dist/Providers/RouteServiceProvider.d.ts +9 -0
- package/dist/Providers/RouteServiceProvider.d.ts.map +1 -0
- package/dist/Providers/RouteServiceProvider.js +22 -0
- package/dist/Providers/RouteServiceProvider.js.map +1 -0
- package/dist/Routing/Controller.d.ts +17 -0
- package/dist/Routing/Controller.d.ts.map +1 -0
- package/dist/Routing/Controller.js +26 -0
- package/dist/Routing/Controller.js.map +1 -0
- package/dist/Routing/Request.d.ts +109 -0
- package/dist/Routing/Request.d.ts.map +1 -0
- package/dist/Routing/Request.js +212 -0
- package/dist/Routing/Request.js.map +1 -0
- package/dist/Routing/Response.d.ts +78 -0
- package/dist/Routing/Response.d.ts.map +1 -0
- package/dist/Routing/Response.js +174 -0
- package/dist/Routing/Response.js.map +1 -0
- package/dist/Routing/Route.d.ts +51 -0
- package/dist/Routing/Route.d.ts.map +1 -0
- package/dist/Routing/Route.js +94 -0
- package/dist/Routing/Route.js.map +1 -0
- package/dist/Routing/Router.d.ts +114 -0
- package/dist/Routing/Router.d.ts.map +1 -0
- package/dist/Routing/Router.js +216 -0
- package/dist/Routing/Router.js.map +1 -0
- package/dist/Support/Facade.d.ts +44 -0
- package/dist/Support/Facade.d.ts.map +1 -0
- package/dist/Support/Facade.js +101 -0
- package/dist/Support/Facade.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Controller.js","sourceRoot":"","sources":["../../src/Routing/Controller.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH,MAAsB,UAAU;IAC9B;;;OAGG;IACO,QAAQ,CAAC,OAAgB,EAAE,KAA0B;QAC7D,0CAA0C;QAC1C,gCAAgC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACI,UAAU,CAAC,MAAc,EAAE,UAAiB;QACjD,OAAQ,IAAY,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;IAC9C,CAAC;CACF;AAjBD,gCAiBC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { IncomingMessage } from 'http';
|
|
2
|
+
import { Route } from './Route';
|
|
3
|
+
/**
|
|
4
|
+
* Request - Laravel's HTTP Request wrapper
|
|
5
|
+
* Illuminate\Http\Request
|
|
6
|
+
*/
|
|
7
|
+
export declare class Request {
|
|
8
|
+
raw: IncomingMessage;
|
|
9
|
+
method: string;
|
|
10
|
+
url: string;
|
|
11
|
+
path: string;
|
|
12
|
+
query: Record<string, any>;
|
|
13
|
+
params: Record<string, any>;
|
|
14
|
+
headers: Record<string, string | string[] | undefined>;
|
|
15
|
+
body: any;
|
|
16
|
+
route?: Route;
|
|
17
|
+
private bodyParsed;
|
|
18
|
+
constructor(req: IncomingMessage);
|
|
19
|
+
/**
|
|
20
|
+
* Parse the request body
|
|
21
|
+
*/
|
|
22
|
+
parseBody(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a header value
|
|
25
|
+
* Laravel: $request->header('content-type')
|
|
26
|
+
*/
|
|
27
|
+
header(name: string, defaultValue?: string): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Get an input value from the request
|
|
30
|
+
* Laravel: $request->input('name')
|
|
31
|
+
*/
|
|
32
|
+
input(key: string, defaultValue?: any): any;
|
|
33
|
+
/**
|
|
34
|
+
* Get a value from query or body
|
|
35
|
+
* Laravel: $request->get('name')
|
|
36
|
+
*/
|
|
37
|
+
get(key: string, defaultValue?: any): any;
|
|
38
|
+
/**
|
|
39
|
+
* Get all inputs
|
|
40
|
+
* Laravel: $request->all()
|
|
41
|
+
*/
|
|
42
|
+
all(): Record<string, any>;
|
|
43
|
+
/**
|
|
44
|
+
* Get only specified inputs
|
|
45
|
+
* Laravel: $request->only(['name', 'email'])
|
|
46
|
+
*/
|
|
47
|
+
only(keys: string[]): Record<string, any>;
|
|
48
|
+
/**
|
|
49
|
+
* Get all inputs except specified
|
|
50
|
+
* Laravel: $request->except(['password'])
|
|
51
|
+
*/
|
|
52
|
+
except(keys: string[]): Record<string, any>;
|
|
53
|
+
/**
|
|
54
|
+
* Determine if the request contains a given input
|
|
55
|
+
* Laravel: $request->has('name')
|
|
56
|
+
*/
|
|
57
|
+
has(key: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Determine if the request contains a non-empty value
|
|
60
|
+
* Laravel: $request->filled('name')
|
|
61
|
+
*/
|
|
62
|
+
filled(key: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Get the route parameter
|
|
65
|
+
* Laravel: $request->route('id')
|
|
66
|
+
*/
|
|
67
|
+
routeParam(key: string, defaultValue?: string): string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Determine if the request is an AJAX request
|
|
70
|
+
* Laravel: $request->ajax()
|
|
71
|
+
*/
|
|
72
|
+
ajax(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Determine if the request expects JSON
|
|
75
|
+
* Laravel: $request->expectsJson()
|
|
76
|
+
*/
|
|
77
|
+
expectsJson(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Determine if the request is sending JSON
|
|
80
|
+
* Laravel: $request->isJson()
|
|
81
|
+
*/
|
|
82
|
+
isJson(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Get the request method
|
|
85
|
+
* Laravel: $request->method()
|
|
86
|
+
*/
|
|
87
|
+
getMethod(): string;
|
|
88
|
+
/**
|
|
89
|
+
* Determine if the request is a specific method
|
|
90
|
+
* Laravel: $request->isMethod('post')
|
|
91
|
+
*/
|
|
92
|
+
isMethod(method: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Get the URL for the request
|
|
95
|
+
* Laravel: $request->url()
|
|
96
|
+
*/
|
|
97
|
+
getUrl(): string;
|
|
98
|
+
/**
|
|
99
|
+
* Get the path for the request
|
|
100
|
+
* Laravel: $request->path()
|
|
101
|
+
*/
|
|
102
|
+
getPath(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Get the IP address of the request
|
|
105
|
+
* Laravel: $request->ip()
|
|
106
|
+
*/
|
|
107
|
+
ip(): string | undefined;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=Request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Request.d.ts","sourceRoot":"","sources":["../../src/Routing/Request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;GAGG;AACH,qBAAa,OAAO;IACX,GAAG,EAAE,eAAe,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IAC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E;;;OAGG;IACH,IAAI,IAAI,OAAO;IAIf;;;OAGG;IACH,WAAW,IAAI,OAAO;IAKtB;;;OAGG;IACH,MAAM,IAAI,OAAO;IAKjB;;;OAGG;IACH,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAIjC;;;OAGG;IACH,MAAM,IAAI,MAAM;IAIhB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,EAAE,IAAI,MAAM,GAAG,SAAS;CAQzB"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Request = void 0;
|
|
4
|
+
const url_1 = require("url");
|
|
5
|
+
const querystring_1 = require("querystring");
|
|
6
|
+
/**
|
|
7
|
+
* Request - Laravel's HTTP Request wrapper
|
|
8
|
+
* Illuminate\Http\Request
|
|
9
|
+
*/
|
|
10
|
+
class Request {
|
|
11
|
+
raw;
|
|
12
|
+
method;
|
|
13
|
+
url;
|
|
14
|
+
path;
|
|
15
|
+
query = {};
|
|
16
|
+
params = {};
|
|
17
|
+
headers;
|
|
18
|
+
body = {};
|
|
19
|
+
route;
|
|
20
|
+
bodyParsed = false;
|
|
21
|
+
constructor(req) {
|
|
22
|
+
this.raw = req;
|
|
23
|
+
this.method = req.method || 'GET';
|
|
24
|
+
this.url = req.url || '/';
|
|
25
|
+
this.headers = req.headers;
|
|
26
|
+
// Parse URL and query string
|
|
27
|
+
const parsed = (0, url_1.parse)(this.url, true);
|
|
28
|
+
this.path = parsed.pathname || '/';
|
|
29
|
+
this.query = parsed.query;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse the request body
|
|
33
|
+
*/
|
|
34
|
+
async parseBody() {
|
|
35
|
+
if (this.bodyParsed) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
let data = '';
|
|
40
|
+
this.raw.on('data', chunk => {
|
|
41
|
+
data += chunk.toString();
|
|
42
|
+
});
|
|
43
|
+
this.raw.on('end', () => {
|
|
44
|
+
try {
|
|
45
|
+
const contentType = this.header('content-type') || '';
|
|
46
|
+
if (contentType.includes('application/json')) {
|
|
47
|
+
this.body = data ? JSON.parse(data) : {};
|
|
48
|
+
}
|
|
49
|
+
else if (contentType.includes('application/x-www-form-urlencoded')) {
|
|
50
|
+
this.body = (0, querystring_1.parse)(data);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.body = data;
|
|
54
|
+
}
|
|
55
|
+
this.bodyParsed = true;
|
|
56
|
+
resolve();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
reject(error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
this.raw.on('error', reject);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get a header value
|
|
67
|
+
* Laravel: $request->header('content-type')
|
|
68
|
+
*/
|
|
69
|
+
header(name, defaultValue) {
|
|
70
|
+
const value = this.headers[name.toLowerCase()];
|
|
71
|
+
return Array.isArray(value) ? value[0] : value || defaultValue;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get an input value from the request
|
|
75
|
+
* Laravel: $request->input('name')
|
|
76
|
+
*/
|
|
77
|
+
input(key, defaultValue) {
|
|
78
|
+
return this.get(key, defaultValue);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get a value from query or body
|
|
82
|
+
* Laravel: $request->get('name')
|
|
83
|
+
*/
|
|
84
|
+
get(key, defaultValue) {
|
|
85
|
+
if (this.query[key] !== undefined) {
|
|
86
|
+
return this.query[key];
|
|
87
|
+
}
|
|
88
|
+
if (this.body[key] !== undefined) {
|
|
89
|
+
return this.body[key];
|
|
90
|
+
}
|
|
91
|
+
return defaultValue;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get all inputs
|
|
95
|
+
* Laravel: $request->all()
|
|
96
|
+
*/
|
|
97
|
+
all() {
|
|
98
|
+
return { ...this.query, ...this.body };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get only specified inputs
|
|
102
|
+
* Laravel: $request->only(['name', 'email'])
|
|
103
|
+
*/
|
|
104
|
+
only(keys) {
|
|
105
|
+
const result = {};
|
|
106
|
+
const all = this.all();
|
|
107
|
+
for (const key of keys) {
|
|
108
|
+
if (all[key] !== undefined) {
|
|
109
|
+
result[key] = all[key];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get all inputs except specified
|
|
116
|
+
* Laravel: $request->except(['password'])
|
|
117
|
+
*/
|
|
118
|
+
except(keys) {
|
|
119
|
+
const all = this.all();
|
|
120
|
+
const result = { ...all };
|
|
121
|
+
for (const key of keys) {
|
|
122
|
+
delete result[key];
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Determine if the request contains a given input
|
|
128
|
+
* Laravel: $request->has('name')
|
|
129
|
+
*/
|
|
130
|
+
has(key) {
|
|
131
|
+
return this.get(key) !== undefined;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Determine if the request contains a non-empty value
|
|
135
|
+
* Laravel: $request->filled('name')
|
|
136
|
+
*/
|
|
137
|
+
filled(key) {
|
|
138
|
+
const value = this.get(key);
|
|
139
|
+
return value !== undefined && value !== null && value !== '';
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get the route parameter
|
|
143
|
+
* Laravel: $request->route('id')
|
|
144
|
+
*/
|
|
145
|
+
routeParam(key, defaultValue) {
|
|
146
|
+
return this.params[key] ?? defaultValue;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Determine if the request is an AJAX request
|
|
150
|
+
* Laravel: $request->ajax()
|
|
151
|
+
*/
|
|
152
|
+
ajax() {
|
|
153
|
+
return this.header('x-requested-with')?.toLowerCase() === 'xmlhttprequest';
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Determine if the request expects JSON
|
|
157
|
+
* Laravel: $request->expectsJson()
|
|
158
|
+
*/
|
|
159
|
+
expectsJson() {
|
|
160
|
+
const accept = this.header('accept') || '';
|
|
161
|
+
return accept.includes('application/json');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Determine if the request is sending JSON
|
|
165
|
+
* Laravel: $request->isJson()
|
|
166
|
+
*/
|
|
167
|
+
isJson() {
|
|
168
|
+
const contentType = this.header('content-type') || '';
|
|
169
|
+
return contentType.includes('application/json');
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get the request method
|
|
173
|
+
* Laravel: $request->method()
|
|
174
|
+
*/
|
|
175
|
+
getMethod() {
|
|
176
|
+
return this.method;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Determine if the request is a specific method
|
|
180
|
+
* Laravel: $request->isMethod('post')
|
|
181
|
+
*/
|
|
182
|
+
isMethod(method) {
|
|
183
|
+
return this.method.toLowerCase() === method.toLowerCase();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get the URL for the request
|
|
187
|
+
* Laravel: $request->url()
|
|
188
|
+
*/
|
|
189
|
+
getUrl() {
|
|
190
|
+
return this.url;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get the path for the request
|
|
194
|
+
* Laravel: $request->path()
|
|
195
|
+
*/
|
|
196
|
+
getPath() {
|
|
197
|
+
return this.path;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get the IP address of the request
|
|
201
|
+
* Laravel: $request->ip()
|
|
202
|
+
*/
|
|
203
|
+
ip() {
|
|
204
|
+
const forwarded = this.header('x-forwarded-for');
|
|
205
|
+
if (forwarded) {
|
|
206
|
+
return Array.isArray(forwarded) ? forwarded[0] : forwarded.split(',')[0];
|
|
207
|
+
}
|
|
208
|
+
return this.raw.socket.remoteAddress;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.Request = Request;
|
|
212
|
+
//# sourceMappingURL=Request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../src/Routing/Request.ts"],"names":[],"mappings":";;;AACA,6BAAwC;AACxC,6CAAkD;AAGlD;;;GAGG;AACH,MAAa,OAAO;IACX,GAAG,CAAkB;IACrB,MAAM,CAAS;IACf,GAAG,CAAS;IACZ,IAAI,CAAS;IACb,KAAK,GAAwB,EAAE,CAAC;IAChC,MAAM,GAAwB,EAAE,CAAC;IACjC,OAAO,CAAgD;IACvD,IAAI,GAAQ,EAAE,CAAC;IACf,KAAK,CAAS;IAEb,UAAU,GAAY,KAAK,CAAC;IAEpC,YAAY,GAAoB;QAC9B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAwD,CAAC;QAE5E,6BAA6B;QAC7B,MAAM,MAAM,GAAG,IAAA,WAAQ,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAA4B,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,IAAI,GAAG,EAAE,CAAC;YAEd,I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ACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,EAAE;QACA,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACjD,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;IACvC,CAAC;CACF;AAvOD,0BAuOC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ServerResponse } from 'http';
|
|
2
|
+
/**
|
|
3
|
+
* Response - Laravel's HTTP Response wrapper
|
|
4
|
+
* Illuminate\Http\Response
|
|
5
|
+
*/
|
|
6
|
+
export declare class Response {
|
|
7
|
+
raw: ServerResponse;
|
|
8
|
+
finished: boolean;
|
|
9
|
+
private statusCode;
|
|
10
|
+
private responseHeaders;
|
|
11
|
+
private cookies;
|
|
12
|
+
constructor(res: ServerResponse);
|
|
13
|
+
/**
|
|
14
|
+
* Set the response status code
|
|
15
|
+
* Laravel: response()->status(404)
|
|
16
|
+
*/
|
|
17
|
+
status(code: number): this;
|
|
18
|
+
/**
|
|
19
|
+
* Set a header on the response
|
|
20
|
+
* Laravel: response()->header('Content-Type', 'application/json')
|
|
21
|
+
*/
|
|
22
|
+
header(name: string, value: string): this;
|
|
23
|
+
/**
|
|
24
|
+
* Set multiple headers
|
|
25
|
+
*/
|
|
26
|
+
headers(headers: Record<string, string>): this;
|
|
27
|
+
/**
|
|
28
|
+
* Set a cookie on the response
|
|
29
|
+
* Laravel: response()->cookie('name', 'value')
|
|
30
|
+
*/
|
|
31
|
+
cookie(name: string, value: string, options?: CookieOptions): this;
|
|
32
|
+
/**
|
|
33
|
+
* Write headers to the response
|
|
34
|
+
*/
|
|
35
|
+
private writeHeaders;
|
|
36
|
+
/**
|
|
37
|
+
* Send a response
|
|
38
|
+
* Laravel: response('Hello World')
|
|
39
|
+
*/
|
|
40
|
+
send(data: any): void;
|
|
41
|
+
/**
|
|
42
|
+
* Send a JSON response
|
|
43
|
+
* Laravel: response()->json(['key' => 'value'])
|
|
44
|
+
*/
|
|
45
|
+
json(data: any, statusCode?: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Send a redirect response
|
|
48
|
+
* Laravel: redirect('/path')
|
|
49
|
+
*/
|
|
50
|
+
redirect(url: string, statusCode?: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Send a download response
|
|
53
|
+
* Laravel: response()->download($path)
|
|
54
|
+
*/
|
|
55
|
+
download(data: Buffer | string, filename: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Send a view response (simplified)
|
|
58
|
+
* Laravel: view('welcome', ['name' => 'John'])
|
|
59
|
+
*/
|
|
60
|
+
view(template: string, data?: Record<string, any>): void;
|
|
61
|
+
/**
|
|
62
|
+
* Serialize a cookie
|
|
63
|
+
*/
|
|
64
|
+
private serializeCookie;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Cookie options
|
|
68
|
+
*/
|
|
69
|
+
export interface CookieOptions {
|
|
70
|
+
maxAge?: number;
|
|
71
|
+
domain?: string;
|
|
72
|
+
path?: string;
|
|
73
|
+
expires?: Date;
|
|
74
|
+
httpOnly?: boolean;
|
|
75
|
+
secure?: boolean;
|
|
76
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=Response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../src/Routing/Response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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AC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;CACtC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Response = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Response - Laravel's HTTP Response wrapper
|
|
6
|
+
* Illuminate\Http\Response
|
|
7
|
+
*/
|
|
8
|
+
class Response {
|
|
9
|
+
raw;
|
|
10
|
+
finished = false;
|
|
11
|
+
statusCode = 200;
|
|
12
|
+
responseHeaders = {};
|
|
13
|
+
cookies = [];
|
|
14
|
+
constructor(res) {
|
|
15
|
+
this.raw = res;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Set the response status code
|
|
19
|
+
* Laravel: response()->status(404)
|
|
20
|
+
*/
|
|
21
|
+
status(code) {
|
|
22
|
+
this.statusCode = code;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Set a header on the response
|
|
27
|
+
* Laravel: response()->header('Content-Type', 'application/json')
|
|
28
|
+
*/
|
|
29
|
+
header(name, value) {
|
|
30
|
+
this.responseHeaders[name] = value;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set multiple headers
|
|
35
|
+
*/
|
|
36
|
+
headers(headers) {
|
|
37
|
+
Object.assign(this.responseHeaders, headers);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set a cookie on the response
|
|
42
|
+
* Laravel: response()->cookie('name', 'value')
|
|
43
|
+
*/
|
|
44
|
+
cookie(name, value, options = {}) {
|
|
45
|
+
this.cookies.push({ name, value, options });
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Write headers to the response
|
|
50
|
+
*/
|
|
51
|
+
writeHeaders() {
|
|
52
|
+
this.raw.statusCode = this.statusCode;
|
|
53
|
+
// Write custom headers
|
|
54
|
+
for (const [name, value] of Object.entries(this.responseHeaders)) {
|
|
55
|
+
this.raw.setHeader(name, value);
|
|
56
|
+
}
|
|
57
|
+
// Write cookies
|
|
58
|
+
if (this.cookies.length > 0) {
|
|
59
|
+
const cookieHeaders = this.cookies.map(({ name, value, options }) => {
|
|
60
|
+
return this.serializeCookie(name, value, options);
|
|
61
|
+
});
|
|
62
|
+
this.raw.setHeader('Set-Cookie', cookieHeaders);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Send a response
|
|
67
|
+
* Laravel: response('Hello World')
|
|
68
|
+
*/
|
|
69
|
+
send(data) {
|
|
70
|
+
if (this.finished) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.writeHeaders();
|
|
74
|
+
if (data === null || data === undefined) {
|
|
75
|
+
this.raw.end();
|
|
76
|
+
}
|
|
77
|
+
else if (typeof data === 'string' || Buffer.isBuffer(data)) {
|
|
78
|
+
this.raw.end(data);
|
|
79
|
+
}
|
|
80
|
+
else if (typeof data === 'object') {
|
|
81
|
+
this.json(data);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.raw.end(String(data));
|
|
86
|
+
}
|
|
87
|
+
this.finished = true;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Send a JSON response
|
|
91
|
+
* Laravel: response()->json(['key' => 'value'])
|
|
92
|
+
*/
|
|
93
|
+
json(data, statusCode) {
|
|
94
|
+
if (this.finished) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (statusCode) {
|
|
98
|
+
this.statusCode = statusCode;
|
|
99
|
+
}
|
|
100
|
+
this.header('Content-Type', 'application/json');
|
|
101
|
+
this.writeHeaders();
|
|
102
|
+
this.raw.end(JSON.stringify(data));
|
|
103
|
+
this.finished = true;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Send a redirect response
|
|
107
|
+
* Laravel: redirect('/path')
|
|
108
|
+
*/
|
|
109
|
+
redirect(url, statusCode = 302) {
|
|
110
|
+
if (this.finished) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.statusCode = statusCode;
|
|
114
|
+
this.header('Location', url);
|
|
115
|
+
this.writeHeaders();
|
|
116
|
+
this.raw.end();
|
|
117
|
+
this.finished = true;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Send a download response
|
|
121
|
+
* Laravel: response()->download($path)
|
|
122
|
+
*/
|
|
123
|
+
download(data, filename) {
|
|
124
|
+
if (this.finished) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.header('Content-Disposition', `attachment; filename="${filename}"`);
|
|
128
|
+
this.header('Content-Type', 'application/octet-stream');
|
|
129
|
+
this.send(data);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Send a view response (simplified)
|
|
133
|
+
* Laravel: view('welcome', ['name' => 'John'])
|
|
134
|
+
*/
|
|
135
|
+
view(template, data = {}) {
|
|
136
|
+
// This would normally render a template
|
|
137
|
+
// For now, just send a basic HTML response
|
|
138
|
+
this.header('Content-Type', 'text/html');
|
|
139
|
+
this.send(`<html><body><h1>View: ${template}</h1><pre>${JSON.stringify(data, null, 2)}</pre></body></html>`);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Serialize a cookie
|
|
143
|
+
*/
|
|
144
|
+
serializeCookie(name, value, options) {
|
|
145
|
+
let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
146
|
+
if (options.maxAge) {
|
|
147
|
+
cookie += `; Max-Age=${options.maxAge}`;
|
|
148
|
+
}
|
|
149
|
+
if (options.domain) {
|
|
150
|
+
cookie += `; Domain=${options.domain}`;
|
|
151
|
+
}
|
|
152
|
+
if (options.path) {
|
|
153
|
+
cookie += `; Path=${options.path}`;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
cookie += '; Path=/';
|
|
157
|
+
}
|
|
158
|
+
if (options.expires) {
|
|
159
|
+
cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
160
|
+
}
|
|
161
|
+
if (options.httpOnly) {
|
|
162
|
+
cookie += '; HttpOnly';
|
|
163
|
+
}
|
|
164
|
+
if (options.secure) {
|
|
165
|
+
cookie += '; Secure';
|
|
166
|
+
}
|
|
167
|
+
if (options.sameSite) {
|
|
168
|
+
cookie += `; SameSite=${options.sameSite}`;
|
|
169
|
+
}
|
|
170
|
+
return cookie;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.Response = Response;
|
|
174
|
+
//# sourceMappingURL=Response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response.js","sourceRoot":"","sources":["../../src/Routing/Response.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,QAAQ;IACZ,GAAG,CAAiB;IACpB,QAAQ,GAAY,KAAK,CAAC;IACzB,UAAU,GAAW,GAAG,CAAC;IACzB,eAAe,GAA2B,EAAE,CAAC;IAC7C,OAAO,GAAmE,EAAE,CAAC;IAErF,YAAY,GAAmB;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAY,EAAE,KAAa;QAChC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,OAA+B;QACrC,MAAM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EAAE,CAAC;YACpB,MAAM,IAAI,aAAa,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QACzD,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,IAAI,YAAY,CAAC;QACzB,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,UAAU,CAAC;QACvB,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,IAAI,cAAc,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAhMD,4BAgMC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Request } from './Request';
|
|
2
|
+
import { Response } from './Response';
|
|
3
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
4
|
+
export type RouteAction = Function | string;
|
|
5
|
+
export type Middleware = (req: Request, res: Response, next: () => void) => void | Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Route - Represents a single route in the application
|
|
8
|
+
* Laravel's Illuminate\Routing\Route
|
|
9
|
+
*/
|
|
10
|
+
export declare class Route {
|
|
11
|
+
uri: string;
|
|
12
|
+
methods: HttpMethod[];
|
|
13
|
+
action: RouteAction;
|
|
14
|
+
middleware: Middleware[];
|
|
15
|
+
name?: string;
|
|
16
|
+
parameters: Record<string, string>;
|
|
17
|
+
private compiled?;
|
|
18
|
+
private parameterNames;
|
|
19
|
+
constructor(methods: HttpMethod | HttpMethod[], uri: string, action: RouteAction);
|
|
20
|
+
/**
|
|
21
|
+
* Compile the route pattern into a regex
|
|
22
|
+
*/
|
|
23
|
+
private compileRoute;
|
|
24
|
+
/**
|
|
25
|
+
* Determine if the route matches the given request
|
|
26
|
+
*/
|
|
27
|
+
matches(method: string, path: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Bind the route parameters from the path
|
|
30
|
+
*/
|
|
31
|
+
bind(path: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Add middleware to the route
|
|
34
|
+
* Laravel: Route::middleware('auth')
|
|
35
|
+
*/
|
|
36
|
+
addMiddleware(middleware: Middleware | Middleware[]): this;
|
|
37
|
+
/**
|
|
38
|
+
* Set the route name
|
|
39
|
+
* Laravel: Route::name('users.index')
|
|
40
|
+
*/
|
|
41
|
+
setName(name: string): this;
|
|
42
|
+
/**
|
|
43
|
+
* Get the route parameters
|
|
44
|
+
*/
|
|
45
|
+
getParameters(): Record<string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a specific parameter value
|
|
48
|
+
*/
|
|
49
|
+
parameter(name: string, defaultValue?: string): string | undefined;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=Route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../../src/Routing/Route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAC1F,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC5C,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjG;;;GAGG;AACH,qBAAa,KAAK;IACT,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,UAAU,EAAE,CAAM;IAC9B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