Files
splatoon3.ink/app/screenshots/HttpServer.mjs
Matt Isenhower 8780463c66 Replace deprecated and unmaintained packages
- Removed mkdirp in favor of native fs.mkdir({ recursive: true })
- Replaced ecstatic (unmaintained since 2021) with sirv
- Replaced jsonpath (security vulnerability) with jsonpath-plus
  - Added jsonpathQuery/jsonpathApply helpers in app/common/util.mjs
- Updated sharp: 0.32.6 → 0.34.5
- Updated puppeteer-core: 23.8.0 → 24.37.3

Vulnerabilities reduced from 40 to 1 (only remaining: axios in
threads-api transitive dependency).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 11:05:49 -08:00

33 lines
610 B
JavaScript

import http from 'http';
import sirv from 'sirv';
export default class HttpServer
{
/** @member {http.Server} */
#server = null;
get port() {
return this.#server.address().port;
}
open() {
return new Promise((resolve, reject) => {
if (this.#server) {
return resolve();
}
const handler = sirv('./dist');
this.#server = http.createServer(handler);
this.#server.on('listening', () => resolve());
this.#server.listen();
});
}
async close() {
if (this.#server) {
await this.#server.close();
this.#server = null;
}
}
}