@satorijs/satori
Advanced tools
Comparing version 1.1.11 to 1.2.0
@@ -38,3 +38,35 @@ var __create = Object.create; | ||
var import_cosmokit3 = require("cosmokit"); | ||
var import_portfinder = require("portfinder"); | ||
// satori/packages/satori/src/listen.ts | ||
function listen(server, { host, port, maxPort = port }) { | ||
return new Promise((resolve, reject) => { | ||
function onListen() { | ||
server.removeListener("error", onError); | ||
resolve(port); | ||
} | ||
__name(onListen, "onListen"); | ||
function onError(err) { | ||
server.removeListener("listening", onListen); | ||
if (!(err.code == "EADDRINUSE" || err.code == "EACCES")) { | ||
return reject(err); | ||
} | ||
port++; | ||
if (port > maxPort) { | ||
return reject(new Error("No open ports available")); | ||
} | ||
testPort(); | ||
} | ||
__name(onError, "onError"); | ||
function testPort() { | ||
server.once("error", onError); | ||
server.once("listening", onListen); | ||
server.listen(port, host); | ||
} | ||
__name(testPort, "testPort"); | ||
testPort(); | ||
}); | ||
} | ||
__name(listen, "listen"); | ||
// satori/packages/satori/src/index.ts | ||
__reExport(src_exports, require("@satorijs/core"), module.exports); | ||
@@ -184,14 +216,8 @@ __reExport(src_exports, require("cosmokit"), module.exports); | ||
import_core3.Context.prototype.start = async function(...args) { | ||
if (this.options.selfUrl) { | ||
this.options.selfUrl = (0, import_cosmokit3.trimSlash)(this.options.selfUrl); | ||
if (this.root.config.selfUrl) { | ||
this.root.config.selfUrl = (0, import_cosmokit3.trimSlash)(this.root.config.selfUrl); | ||
} | ||
if (this.options.port) { | ||
this.options.port = await (0, import_portfinder.getPortPromise)({ | ||
port: this.options.port, | ||
stopPort: this.options.maxPort || this.options.port | ||
}); | ||
const { host, port } = this.options; | ||
await new Promise((resolve) => { | ||
this.router._http.listen(port, host, resolve); | ||
}); | ||
if (this.root.config.port) { | ||
const { host, port } = this.root.config; | ||
await listen(this.router._http, this.root.config); | ||
logger.info("server listening at %c", `http://${host}:${port}`); | ||
@@ -198,0 +224,0 @@ this.on("dispose", () => { |
{ | ||
"name": "@satorijs/satori", | ||
"description": "Core components of Satorijs", | ||
"version": "1.1.11", | ||
"version": "1.2.0", | ||
"main": "lib/index.js", | ||
@@ -35,3 +35,3 @@ "typings": "lib/index.d.ts", | ||
"@koa/router": "^10.1.1", | ||
"@satorijs/core": "^1.1.11", | ||
"@satorijs/core": "^1.2.0", | ||
"@types/koa": "*", | ||
@@ -48,3 +48,2 @@ "@types/koa__router": "*", | ||
"path-to-regexp": "^6.2.1", | ||
"portfinder": "^1.0.28", | ||
"schemastery": "^3.5.4", | ||
@@ -51,0 +50,0 @@ "socks-proxy-agent": "^5.0.1", |
Sorry, the diff of this file is not supported yet
33650
16
10
376
- Removedportfinder@^1.0.28
- Removedasync@2.6.4(transitive)
- Removeddebug@3.2.7(transitive)
- Removedlodash@4.17.21(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedportfinder@1.0.33(transitive)
Updated@satorijs/core@^1.2.0