draft: refactor project so it sits on top of a standalone app

This commit is contained in:
2020-05-11 15:34:47 +02:00
parent a9ee5acc1c
commit f97e8455fc
13068 changed files with 1735502 additions and 866 deletions
+31
View File
@@ -0,0 +1,31 @@
var http = require('http')
var url = require('url')
var https = module.exports
for (var key in http) {
if (http.hasOwnProperty(key)) https[key] = http[key]
}
https.request = function (params, cb) {
params = validateParams(params)
return http.request.call(this, params, cb)
}
https.get = function (params, cb) {
params = validateParams(params)
return http.get.call(this, params, cb)
}
function validateParams (params) {
if (typeof params === 'string') {
params = url.parse(params)
}
if (!params.protocol) {
params.protocol = 'https:'
}
if (params.protocol !== 'https:') {
throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"')
}
return params
}