rubik-telegram
Advanced tools
Comparing version 1.0.4 to 1.1.0
module.exports = { | ||
"parser": "babel-eslint", | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": ["eslint:recommended"], | ||
"rules": { | ||
"no-console": ["error", { "allow": ["warn", "error", "info", "dir", "time", "timeEnd"] }], | ||
"no-cond-assign": [0, "except-parens"], | ||
"require-yield": [1] | ||
}, | ||
"globals": { window: true, fetch: true } | ||
} | ||
"env": { | ||
"browser": true, | ||
"commonjs": true, | ||
"node": true, | ||
"es2021": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 12 | ||
}, | ||
"rules": { | ||
} | ||
}; |
const { Kubik } = require('rubik-main'); | ||
const FormData = require('form-data'); | ||
const fetch = require('node-fetch'); | ||
@@ -56,16 +57,13 @@ const isObject = require('lodash/isObject'); | ||
async request(name, body, token, host) { | ||
if (isObject(body)) { | ||
const headers = {}; | ||
if (body instanceof FormData) { | ||
Object.assign(headers, body.getHeaders()); | ||
} else if (isObject(body)) { | ||
body = JSON.stringify(body); | ||
headers['Content-Type'] = 'application/json'; | ||
} | ||
const url = this.getUrl(name, token, host); | ||
const request = await fetch(url, { method: 'POST', body, headers }); | ||
const request = await fetch(url, { | ||
method: 'POST', | ||
body, | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
const result = await request.json(); | ||
@@ -72,0 +70,0 @@ |
module.exports = { | ||
verbose: true, | ||
browser: false, | ||
testEnvironment: 'node', | ||
@@ -5,0 +4,0 @@ transform: {}, |
{ | ||
"name": "rubik-telegram", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Telegram Bot Api kubik for the Rubik application system", | ||
@@ -25,4 +25,5 @@ "main": "classes/Telegram.js", | ||
"dependencies": { | ||
"lodash": "^4.17.15", | ||
"node-fetch": "^2.6.0" | ||
"form-data": "^4.0.0", | ||
"lodash": "^4.17.21", | ||
"node-fetch": "^2.6.1" | ||
}, | ||
@@ -33,7 +34,6 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"babel-eslint": "^10.1.0", | ||
"eslint": "^6.8.0", | ||
"jest": "^25.2.7", | ||
"eslint": "^7.23.0", | ||
"jest": "^26.6.3", | ||
"rubik-main": "^2.2.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# rubik-micro | ||
# rubik-telegram | ||
Telegram's Bot API kubik for the Rubik | ||
@@ -3,0 +3,0 @@ |
/* global describe test expect */ | ||
const path = require('path'); | ||
const { Kubiks: { Config } } = require('rubik-main'); | ||
const FormData = require('form-data'); | ||
@@ -50,2 +51,11 @@ const { createApp, createKubik } = require('rubik-main/tests/helpers/creators'); | ||
test('Отправляет запрос с form-data', async () => { | ||
const app = getApp(); | ||
const kubik = createKubik(Telegram, app); | ||
await app.up(); | ||
const response = await kubik.getMe(new FormData()); | ||
expect(response.ok).toBe(true); | ||
await app.down(); | ||
}); | ||
test('Запрос с невалидным токеном падает', async () => { | ||
@@ -52,0 +62,0 @@ const app = getApp(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20702
3
235
4
+ Addedform-data@^4.0.0
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
Updatedlodash@^4.17.21
Updatednode-fetch@^2.6.1