mirror of
https://github.com/Wessel/wumpfetch.git
synced 2026-06-06 07:35:42 +02:00
18 lines
598 B
JavaScript
18 lines
598 B
JavaScript
const req = require('./model/WumpRequest');
|
|
const pkg = require('../package.json');
|
|
|
|
const common = [ 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH' ];
|
|
|
|
module.exports = (url, method) => {
|
|
return new req(url, method);
|
|
};
|
|
|
|
common.forEach((v) => {
|
|
module.exports[v.toLowerCase()] = (url, method) => {
|
|
if (typeof url === 'string') return new req(url, { method: v, ...method });
|
|
else return new req({ method: v, ...url }, method);
|
|
}
|
|
});
|
|
|
|
module.exports.version = pkg.version;
|
|
module.exports.userAgent = `${pkg.name}/${pkg.version} (${pkg.repository.url})`; |