REST API upgrade
This commit is contained in:
@@ -31,7 +31,36 @@ module.exports = class http_client {
|
||||
// post the data
|
||||
request.write(data)
|
||||
request.end()
|
||||
|
||||
}
|
||||
#ip
|
||||
#port
|
||||
}
|
||||
|
||||
module.exports.post = async (options, callback_res, callback_err) => {
|
||||
http.post(options, function(res) {
|
||||
var body_chunks = []
|
||||
res.on('data', chunk => {
|
||||
body_chunks.push(chunk)
|
||||
}).on('end', () => {
|
||||
var body = Buffer.concat(body_chunks)
|
||||
callback_res(body)
|
||||
})
|
||||
}).on('error', err => {
|
||||
callback_err(err)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.get = async (options, callback_res, callback_err) => {
|
||||
http.get(options, function(res) {
|
||||
var body_chunks = []
|
||||
res.on('data', chunk => {
|
||||
body_chunks.push(chunk)
|
||||
}).on('end', () => {
|
||||
var body = Buffer.concat(body_chunks)
|
||||
callback_res(body)
|
||||
})
|
||||
}).on('error', err => {
|
||||
callback_err(err)
|
||||
})
|
||||
}
|
||||
@@ -24,7 +24,7 @@ module.exports = class logger {
|
||||
arg.forEach(value => {
|
||||
args += util.format(value) + ' '
|
||||
})
|
||||
args = (node_time.create().format('Y-m-d H:M:S')).toString() + ((message != '') ? ': ' + message : '') + ': ' + args
|
||||
args = (node_time.create().format('d-m-Y H:M:S')).toString() + ((message != '') ? ': ' + message : '') + ': ' + args
|
||||
console.log(this.#filename + ': ' + args)
|
||||
fs.appendFileSync(this.#filepath, args + '\n')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user