Many fixes!

This commit is contained in:
Wessel T
2019-04-05 17:15:24 +02:00
parent 28bbb58892
commit 7ee8d3bf6b
12 changed files with 230 additions and 145 deletions

20
lib/index.js Normal file
View File

@@ -0,0 +1,20 @@
const common = [ 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH' ];
const request = require('./model/WumpRequest');
const { version } = require('../package.json');
module.exports = (url, method) => {
return new request(url, method);
};
common.forEach((v) => {
module.exports[v.toLowerCase()] = (url, method) => {
if (typeof url === 'string') {
return new request(url, { method: v, ...method });
} else {
return new request({ method: v, ...url }, method);
}
}
});
module.exports.version = version;
module.exports.userAgent = `wumpfetch/${version} (https://github.com/PassTheWessel/wumpfetch)`;