minimalistic-server 0.0.21 → 0.0.23

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.
Files changed (2) hide show
  1. package/index.mjs +20 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as http from 'node:http';
2
2
  import * as querystring from "node:querystring";
3
3
  import * as fs from "node:fs/promises";
4
+ import * as tls from "node:tls";
4
5
 
5
6
  const servers = new Map();
6
7
  const keepAliveTimeout = 20000;
@@ -718,6 +719,7 @@ export function getServerFsPromiseModule() {
718
719
 
719
720
  export function setServerFsPromiseModule(fsPromiseModule) {
720
721
  currentFsPromiseModule = fsPromiseModule;
722
+ clearStaticCache();
721
723
  }
722
724
 
723
725
  export class UploadedFile {
@@ -793,6 +795,24 @@ export class Request {
793
795
  return this.#headers;
794
796
  }
795
797
 
798
+ getPort() {
799
+ return this.#request.socket.address().port;
800
+ }
801
+
802
+ getProtocol() {
803
+ const socket = this.#request.socket;
804
+
805
+ if (socket instanceof tls.TLSSocket && socket.encrypted) {
806
+ return 'https';
807
+ }
808
+
809
+ return 'http';
810
+ }
811
+
812
+ getHost() {
813
+ return this.#request.headers.host;
814
+ }
815
+
796
816
  getPath() {
797
817
  return this.#path;
798
818
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minimalistic-server",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "engines" : {
5
5
  "npm" : ">=8.6.0",
6
6
  "node" : ">=22.0.0"