yedra 0.13.2 → 0.13.3
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/dist/routing/app.d.ts +6 -1
- package/dist/routing/app.js +9 -3
- package/package.json +1 -1
package/dist/routing/app.d.ts
CHANGED
|
@@ -36,7 +36,12 @@ export declare class Yedra {
|
|
|
36
36
|
url: string;
|
|
37
37
|
}[];
|
|
38
38
|
}): object;
|
|
39
|
-
listen(port: number
|
|
39
|
+
listen(port: number, options?: {
|
|
40
|
+
tls?: {
|
|
41
|
+
key: string;
|
|
42
|
+
cert: string;
|
|
43
|
+
};
|
|
44
|
+
}): Context;
|
|
40
45
|
private static errorResponse;
|
|
41
46
|
private matchRestRoute;
|
|
42
47
|
private matchWsRoute;
|
package/dist/routing/app.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
2
|
-
import { createServer } from 'node:http';
|
|
2
|
+
import { createServer as createHttpServer } from 'node:http';
|
|
3
|
+
import { createServer as createHttpsServer } from 'node:https';
|
|
3
4
|
import { extname, join } from 'node:path';
|
|
4
5
|
import mime from 'mime';
|
|
5
6
|
import { WebSocketServer } from 'ws';
|
|
@@ -129,8 +130,13 @@ export class Yedra {
|
|
|
129
130
|
paths,
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
|
-
listen(port) {
|
|
133
|
-
const server =
|
|
133
|
+
listen(port, options) {
|
|
134
|
+
const server = options?.tls === undefined
|
|
135
|
+
? createHttpServer()
|
|
136
|
+
: createHttpsServer({
|
|
137
|
+
key: options.tls.key,
|
|
138
|
+
cert: options.tls.cert,
|
|
139
|
+
});
|
|
134
140
|
server.on('request', (req, res) => {
|
|
135
141
|
const url = new URL(req.url, 'http://localhost');
|
|
136
142
|
const begin = Date.now();
|