objective-http 1.2.3 → 1.2.4

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/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"objective-http","version":"1.2.3","description":"Proxy classes for creating a http server","keywords":["web","web-server","http","http-server","oop"],"author":{"name":"volatilization","email":"volatilization@yandex.ru"},"repository":{"url":"git+https://github.com/volatilization/objective-http.git"},"license":"LGPL-3.0-only","main":"src/js/index.js"}
1
+ {"name":"objective-http","version":"1.2.4","description":"Proxy classes for creating a http server","keywords":["web","web-server","http","http-server","oop"],"author":{"name":"volatilization","email":"volatilization@yandex.ru"},"repository":{"url":"git+https://github.com/volatilization/objective-http.git"},"license":"LGPL-3.0-only","main":"src/js/index.js"}
@@ -8,21 +8,20 @@ module.exports = class Bunttp {
8
8
  }
9
9
 
10
10
  createServer(cb) {
11
- this.#serverConfig.fetch = cb;
12
- return this;
11
+ return new Bunttp({fetch: cb});
13
12
  }
14
13
 
15
14
  listen(options, cb) {
16
- this.#serverConfig.port = options.port;
17
- this.#server = Bun.serve(this.#serverConfig);
15
+ const config = {...this.#serverConfig, port: options.port};
16
+ const server = Bun.serve(config);
18
17
  cb();
19
- return this;
18
+ return new Bunttp(config, server);
20
19
  }
21
20
 
22
21
  close(cb) {
23
- this.#server.stop();
22
+ const server = this.#server.stop();
24
23
  cb();
25
- return this;
24
+ return new Bunttp(this.#serverConfig, server);
26
25
  }
27
26
 
28
27
  request = fetch;
package/src/js/index.js CHANGED
@@ -2,7 +2,7 @@ module.exports = {
2
2
  server: require('./server'),
3
3
  client: require('./client'),
4
4
  bun: {
5
- server: {...require('./server'), ...require('./bun/').server},
5
+ server: {...require('./server'), ...require('./bun').server},
6
6
  client: {...require('./client'), ...require('./bun').client},
7
7
  bunttp: require('./bun').bunttp
8
8
  }
@@ -3,20 +3,20 @@ module.exports = class Server {
3
3
  #options;
4
4
  #request;
5
5
  #response;
6
- #http;
6
+ #createServerFunction;
7
7
  #server;
8
8
 
9
- constructor(endpoints, options, request, response, http, server) {
9
+ constructor(endpoints, options, request, response, createServerFunction, server) {
10
10
  this.#endpoints = endpoints;
11
11
  this.#options = options;
12
12
  this.#request = request;
13
13
  this.#response = response;
14
- this.#http = http;
14
+ this.#createServerFunction = createServerFunction;
15
15
  this.#server = server;
16
16
  }
17
17
 
18
18
  start() {
19
- const server = this.#http.createServer(async (requestStream, responseStream) => {
19
+ const server = this.#createServerFunction(async (requestStream, responseStream) => {
20
20
  try {
21
21
  return await (this.#response
22
22
  .copy(await this.#endpoints
@@ -53,7 +53,7 @@ module.exports = class Server {
53
53
  this.#options,
54
54
  this.#request,
55
55
  this.#response,
56
- this.#http,
56
+ this.#createServerFunction,
57
57
  server));
58
58
  }
59
59
  );
@@ -68,7 +68,7 @@ module.exports = class Server {
68
68
  this.#options,
69
69
  this.#request,
70
70
  this.#response,
71
- this.#http))
71
+ this.#createServerFunction))
72
72
  );
73
73
  });
74
74
  }