@nx.js/http 0.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/dist/index.d.ts +60 -0
- package/dist/index.js +237 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Nathan Rajlich
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference types="nxjs-runtime" />
|
|
2
|
+
/**
|
|
3
|
+
* Handler function for processing an HTTP request.
|
|
4
|
+
*/
|
|
5
|
+
export type ServerHandler = (req: Request) => Response | Promise<Response>;
|
|
6
|
+
/**
|
|
7
|
+
* Options object for the {@link listen | `http.listen()`} function.
|
|
8
|
+
*/
|
|
9
|
+
export interface ListenOptions extends Omit<Switch.ListenOptions, 'accept'> {
|
|
10
|
+
fetch: ServerHandler;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a socket handler function which accepts a socket
|
|
14
|
+
* event and parses the incoming data as an HTTP request.
|
|
15
|
+
*
|
|
16
|
+
* @note This is a low-level function which usually should not be used directly. See {@link listen | `http.listen()`} instead.
|
|
17
|
+
*
|
|
18
|
+
* @param handler The HTTP handler function to invoke when an HTTP request is received
|
|
19
|
+
*/
|
|
20
|
+
export declare function createServerHandler(handler: ServerHandler): ({ socket }: Switch.SocketEvent) => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an HTTP handler function which serves file contents from the filesystem.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
*
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const fileHandler = http.createStaticFileHandler('sdmc:/switch/');
|
|
28
|
+
*
|
|
29
|
+
* http.listen({
|
|
30
|
+
* port: 8080,
|
|
31
|
+
* async fetch(req) {
|
|
32
|
+
* let res = await fileHandler(req);
|
|
33
|
+
* if (!res) {
|
|
34
|
+
* res = new Response('File not found', { status: 404 });
|
|
35
|
+
* }
|
|
36
|
+
* return res;
|
|
37
|
+
* }
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param root Root directory where static files are served from
|
|
42
|
+
*/
|
|
43
|
+
export declare function createStaticFileHandler(root: Switch.PathLike): (req: Request) => Promise<Response | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates an HTTP server and listens on the `port` number specified in the options object.
|
|
46
|
+
* The `fetch` function will be invoked upon receiving an HTTP request.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
*
|
|
50
|
+
* ```typescript
|
|
51
|
+
* http.listen({
|
|
52
|
+
* port: 8080,
|
|
53
|
+
* fetch(req) {
|
|
54
|
+
* console.log(`Got HTTP ${req.method} request for "${req.url}"`);
|
|
55
|
+
* return new Response('Hello World!');
|
|
56
|
+
* }
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function listen(opts: ListenOptions): Switch.Server;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import mime from 'mime';
|
|
2
|
+
const decoder = new TextDecoder();
|
|
3
|
+
const encoder = new TextEncoder();
|
|
4
|
+
function indexOfEol(arr, offset) {
|
|
5
|
+
for (let i = offset; i < arr.length - 1; i++) {
|
|
6
|
+
if (arr[i] === 13 && arr[i + 1] === 10) {
|
|
7
|
+
return i;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return -1;
|
|
11
|
+
}
|
|
12
|
+
function concat(a, b) {
|
|
13
|
+
const c = new Uint8Array(a.length + b.length);
|
|
14
|
+
c.set(a, 0);
|
|
15
|
+
c.set(b, a.length);
|
|
16
|
+
return c;
|
|
17
|
+
}
|
|
18
|
+
async function* headersIterator(reader) {
|
|
19
|
+
let leftover = null;
|
|
20
|
+
while (true) {
|
|
21
|
+
const next = await reader.read();
|
|
22
|
+
if (next.done)
|
|
23
|
+
throw new Error('Stream closed before end of headers');
|
|
24
|
+
const chunk = leftover
|
|
25
|
+
? concat(leftover, next.value)
|
|
26
|
+
: next.value;
|
|
27
|
+
let pos = 0;
|
|
28
|
+
while (true) {
|
|
29
|
+
const eol = indexOfEol(chunk, pos);
|
|
30
|
+
if (eol === -1) {
|
|
31
|
+
leftover = chunk.slice(pos);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
const line = decoder.decode(chunk.slice(pos, eol));
|
|
35
|
+
pos = eol + 2;
|
|
36
|
+
if (line) {
|
|
37
|
+
yield { line };
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// end of headers
|
|
41
|
+
leftover = chunk.slice(pos);
|
|
42
|
+
yield { line: null, leftover };
|
|
43
|
+
reader.releaseLock();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const STATUS_CODES = {
|
|
50
|
+
'100': 'Continue',
|
|
51
|
+
'101': 'Switching Protocols',
|
|
52
|
+
'102': 'Processing',
|
|
53
|
+
'103': 'Early Hints',
|
|
54
|
+
'200': 'OK',
|
|
55
|
+
'201': 'Created',
|
|
56
|
+
'202': 'Accepted',
|
|
57
|
+
'203': 'Non-Authoritative Information',
|
|
58
|
+
'204': 'No Content',
|
|
59
|
+
'205': 'Reset Content',
|
|
60
|
+
'206': 'Partial Content',
|
|
61
|
+
'207': 'Multi-Status',
|
|
62
|
+
'208': 'Already Reported',
|
|
63
|
+
'226': 'IM Used',
|
|
64
|
+
'300': 'Multiple Choices',
|
|
65
|
+
'301': 'Moved Permanently',
|
|
66
|
+
'302': 'Found',
|
|
67
|
+
'303': 'See Other',
|
|
68
|
+
'304': 'Not Modified',
|
|
69
|
+
'305': 'Use Proxy',
|
|
70
|
+
'307': 'Temporary Redirect',
|
|
71
|
+
'308': 'Permanent Redirect',
|
|
72
|
+
'400': 'Bad Request',
|
|
73
|
+
'401': 'Unauthorized',
|
|
74
|
+
'402': 'Payment Required',
|
|
75
|
+
'403': 'Forbidden',
|
|
76
|
+
'404': 'Not Found',
|
|
77
|
+
'405': 'Method Not Allowed',
|
|
78
|
+
'406': 'Not Acceptable',
|
|
79
|
+
'407': 'Proxy Authentication Required',
|
|
80
|
+
'408': 'Request Timeout',
|
|
81
|
+
'409': 'Conflict',
|
|
82
|
+
'410': 'Gone',
|
|
83
|
+
'411': 'Length Required',
|
|
84
|
+
'412': 'Precondition Failed',
|
|
85
|
+
'413': 'Payload Too Large',
|
|
86
|
+
'414': 'URI Too Long',
|
|
87
|
+
'415': 'Unsupported Media Type',
|
|
88
|
+
'416': 'Range Not Satisfiable',
|
|
89
|
+
'417': 'Expectation Failed',
|
|
90
|
+
'418': "I'm a Teapot",
|
|
91
|
+
'421': 'Misdirected Request',
|
|
92
|
+
'422': 'Unprocessable Entity',
|
|
93
|
+
'423': 'Locked',
|
|
94
|
+
'424': 'Failed Dependency',
|
|
95
|
+
'425': 'Too Early',
|
|
96
|
+
'426': 'Upgrade Required',
|
|
97
|
+
'428': 'Precondition Required',
|
|
98
|
+
'429': 'Too Many Requests',
|
|
99
|
+
'431': 'Request Header Fields Too Large',
|
|
100
|
+
'451': 'Unavailable For Legal Reasons',
|
|
101
|
+
'500': 'Internal Server Error',
|
|
102
|
+
'501': 'Not Implemented',
|
|
103
|
+
'502': 'Bad Gateway',
|
|
104
|
+
'503': 'Service Unavailable',
|
|
105
|
+
'504': 'Gateway Timeout',
|
|
106
|
+
'505': 'HTTP Version Not Supported',
|
|
107
|
+
'506': 'Variant Also Negotiates',
|
|
108
|
+
'507': 'Insufficient Storage',
|
|
109
|
+
'508': 'Loop Detected',
|
|
110
|
+
'509': 'Bandwidth Limit Exceeded',
|
|
111
|
+
'510': 'Not Extended',
|
|
112
|
+
'511': 'Network Authentication Required',
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Creates a socket handler function which accepts a socket
|
|
116
|
+
* event and parses the incoming data as an HTTP request.
|
|
117
|
+
*
|
|
118
|
+
* @note This is a low-level function which usually should not be used directly. See {@link listen | `http.listen()`} instead.
|
|
119
|
+
*
|
|
120
|
+
* @param handler The HTTP handler function to invoke when an HTTP request is received
|
|
121
|
+
*/
|
|
122
|
+
export function createServerHandler(handler) {
|
|
123
|
+
return async function ({ socket }) {
|
|
124
|
+
const reqHeaders = new Headers();
|
|
125
|
+
const r = socket.readable.getReader();
|
|
126
|
+
const hi = headersIterator(r);
|
|
127
|
+
// Parse request headers
|
|
128
|
+
const firstLine = await hi.next();
|
|
129
|
+
if (firstLine.done || !firstLine.value.line) {
|
|
130
|
+
throw new Error('Failed to read response header');
|
|
131
|
+
}
|
|
132
|
+
const [method, path, httpVersion] = firstLine.value.line.split(' ');
|
|
133
|
+
let leftover;
|
|
134
|
+
for await (const v of hi) {
|
|
135
|
+
if (typeof v.line === 'string') {
|
|
136
|
+
const col = v.line.indexOf(':');
|
|
137
|
+
const name = v.line.slice(0, col);
|
|
138
|
+
const value = v.line.slice(col + 1).trim();
|
|
139
|
+
reqHeaders.set(name, value);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
leftover = v.leftover;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const host = reqHeaders.get('host');
|
|
146
|
+
const req = new Request(`http://${host}${path}`, {
|
|
147
|
+
method,
|
|
148
|
+
headers: reqHeaders,
|
|
149
|
+
});
|
|
150
|
+
const res = await handler(req);
|
|
151
|
+
res.headers.set('connection', 'close');
|
|
152
|
+
let headersStr = '';
|
|
153
|
+
for (const [k, v] of res.headers) {
|
|
154
|
+
headersStr += `${k}: ${v}\r\n`;
|
|
155
|
+
}
|
|
156
|
+
const statusText = res.statusText || STATUS_CODES[res.status];
|
|
157
|
+
const resHeader = `${httpVersion} ${res.status} ${statusText}\r\n${headersStr}\r\n`;
|
|
158
|
+
const w = socket.writable.getWriter();
|
|
159
|
+
w.write(encoder.encode(resHeader));
|
|
160
|
+
if (res.body) {
|
|
161
|
+
w.releaseLock();
|
|
162
|
+
await res.body.pipeTo(socket.writable);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
await w.close();
|
|
166
|
+
}
|
|
167
|
+
socket.close();
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Creates an HTTP handler function which serves file contents from the filesystem.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
*
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const fileHandler = http.createStaticFileHandler('sdmc:/switch/');
|
|
177
|
+
*
|
|
178
|
+
* http.listen({
|
|
179
|
+
* port: 8080,
|
|
180
|
+
* async fetch(req) {
|
|
181
|
+
* let res = await fileHandler(req);
|
|
182
|
+
* if (!res) {
|
|
183
|
+
* res = new Response('File not found', { status: 404 });
|
|
184
|
+
* }
|
|
185
|
+
* return res;
|
|
186
|
+
* }
|
|
187
|
+
* });
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @param root Root directory where static files are served from
|
|
191
|
+
*/
|
|
192
|
+
export function createStaticFileHandler(root) {
|
|
193
|
+
if (!String(root).endsWith('/')) {
|
|
194
|
+
throw new Error('`root` directory must end with a "/"');
|
|
195
|
+
}
|
|
196
|
+
return async function (req) {
|
|
197
|
+
const { pathname } = new URL(req.url);
|
|
198
|
+
const url = new URL(pathname.slice(1), root);
|
|
199
|
+
const stat = await Switch.stat(url);
|
|
200
|
+
if (!stat)
|
|
201
|
+
return null;
|
|
202
|
+
// TODO: replace with readable stream API
|
|
203
|
+
const data = await Switch.readFile(url);
|
|
204
|
+
if (!data)
|
|
205
|
+
return null;
|
|
206
|
+
return new Response(data, {
|
|
207
|
+
headers: {
|
|
208
|
+
'content-length': String(data.byteLength),
|
|
209
|
+
'content-type': mime.getType(pathname) || 'application/octet-stream',
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Creates an HTTP server and listens on the `port` number specified in the options object.
|
|
216
|
+
* The `fetch` function will be invoked upon receiving an HTTP request.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
*
|
|
220
|
+
* ```typescript
|
|
221
|
+
* http.listen({
|
|
222
|
+
* port: 8080,
|
|
223
|
+
* fetch(req) {
|
|
224
|
+
* console.log(`Got HTTP ${req.method} request for "${req.url}"`);
|
|
225
|
+
* return new Response('Hello World!');
|
|
226
|
+
* }
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
export function listen(opts) {
|
|
231
|
+
const handler = createServerHandler(opts.fetch);
|
|
232
|
+
return Switch.listen({
|
|
233
|
+
...opts,
|
|
234
|
+
accept: handler,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAcxB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,SAAS,UAAU,CAAC,GAAsB,EAAE,MAAc;IACzD,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YACxC,OAAO,CAAC,CAAC;QACV,CAAC;IACF,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACX,CAAC;AAED,SAAS,MAAM,CAAC,CAAa,EAAE,CAAa;IAC3C,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACZ,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,CAAC,CAAC;AACV,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,eAAe,CAC9B,MAA+C;IAE/C,IAAI,QAAQ,GAAsB,IAAI,CAAC;IACvC,OAAO,IAAI,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC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nx.js/http",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "HTTP server for nx.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@types/mime-types": "^2.1.4",
|
|
14
|
+
"typescript": "^5.3.2",
|
|
15
|
+
"nxjs-runtime": "0.0.37"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"nx.js",
|
|
19
|
+
"switch",
|
|
20
|
+
"http",
|
|
21
|
+
"server"
|
|
22
|
+
],
|
|
23
|
+
"author": "Nathan Rajlich <n@n8.io>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"mime": "^4.0.1"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc"
|
|
30
|
+
}
|
|
31
|
+
}
|