mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00

* feat!: update `engines.node` to `^14.17.0 || ^16.13.0 || >=18.0.0` * deps: nopt@^7.0.0 * feat: replace npmlog with proc-log * deps: standard@17.0.0 and fix linting errors * deps: which@3.0.0 - this also promiisifies the build command * deps: glob@8.0.3 * feat: drop rimraf dependency * fix: use fs/promises in favor of fs.promises
27 lines
643 B
JavaScript
27 lines
643 B
JavaScript
'use strict'
|
|
|
|
const http = require('http')
|
|
const https = require('https')
|
|
const server = http.createServer(handler)
|
|
const port = +process.argv[2]
|
|
const prefix = process.argv[3]
|
|
const upstream = process.argv[4]
|
|
let calls = 0
|
|
|
|
server.listen(port)
|
|
|
|
function handler (req, res) {
|
|
if (req.url.indexOf(prefix) !== 0) {
|
|
throw new Error('request url [' + req.url + '] does not start with [' + prefix + ']')
|
|
}
|
|
|
|
const upstreamUrl = upstream + req.url.substring(prefix.length)
|
|
https.get(upstreamUrl, function (ures) {
|
|
ures.on('end', function () {
|
|
if (++calls === 2) {
|
|
server.close()
|
|
}
|
|
})
|
|
ures.pipe(res)
|
|
})
|
|
}
|