1.0.7 • Published 6 years ago

blitz-js-query v1.0.7

Weekly downloads
13
License
MIT
Repository
github
Last release
6 years ago

blitz-js-query

Connection packages to connect to blitz.js API nodes. Choose your target platform from the available branches.

Installation

npm install blitz-js-query

Other Supported Platforms

PlatformInstallDescription
pythonpipFor usage in Python. Might have to enable HTTP explicitly since Socket.io isn't that well maintained on python.

Usage

const Blitz = require('blitz-js-query')
const blitz = new Blitz()

blitz.get('/foo').then(res => console.log(res.body)) // bar

Configuration

const Blitz = require('blitz-js-query')
const blitz = new Blitz({key: value})
KeyDefaultDescription
api_url'http://localhost:3003/'URL of blitz.js API-Node to connect to
auth_url'http://localhost:3030/'URL of blitz.js Auth-Node to authenticate with
namespace'/'Socket.io namespace to connect to
user_keynullUser key obtained via Auth-Node registration
user_secretnullUser secret obtained via Auth-Node
ignore_limiterfalseWhether or not to disable the default rate limit adaptions. Disabling this only makes sense if you connect as a user who won't face rate limits. If you disable it anyway, expect all your requests to get blocked.

API

RESTful methods

blitz.get(url)

Sends a GET request to the API-Node

ArgumentDescriptionDefault
urlURL to request, without domain. e.g. /foo.None
blitz.post(url, body)

Sends a POST request to the API-Node

ArgumentDescriptionDefault
urlURL to request, without domain. e.g. /foo.None
bodyData to send to endpoint. Can be any data type.None
blitz.put(url, body)

Sends a PUT request to the API-Node

ArgumentDescriptionDefault
urlURL to request, without domain. e.g. /foo.None
bodyData to send to endpoint. Can be any data type.None
blitz.patch(url, body)

Sends a PATCH request to the API-Node

ArgumentDescriptionDefault
urlURL to request, without domain. e.g. /foo.None
bodyData to send to endpoint. Can be any data type.None
blitz.delete(url, body)

Sends a DELETE request to the API-Node

ArgumentDescriptionDefault
urlURL to request, without domain. e.g. /foo.None
bodyData to send to endpoint. Can be any data type.None

Pub/Sub

blitz.subscribe(endpoint, fn)

Subscribe to updates on a specific endpoint.

ArgumentDescriptionDefault
endpointURL to listen for updates on, without domain. e.g. '/foo'None
fnFunction to run when updates are received. Takes the new data as argument.None

Authentication

blitz.login(user, secret)

Re-authorizes as a specific user at runtime. Usually users should be logged in through the constructor options.

ArgumentDescriptionDefault
userUser id, equal to user_key when registering.None
secretUser password, equal to user_secret when registering.None
blitz.setRefreshToken(token)

Manually set the refresh token. This way user credentials needn't be exposed.

ArgumentDescriptionDefault
tokenrefresh_token to use.None
blitz.getRefreshToken()

Retrieve current refresh token. Will await any existing authentication process. Useful if the initial login can be done through user/pass but the refresh token needs to be stored for subsequent logins.

blitz.setAccessToken(token)

Manually set the access token. This will expire on the next refresh.

ArgumentDescriptionDefault
tokenaccess_token to use.None
blitz.getRefreshToken()

Retrieve current access token. Will await any existing authentication process.

Socket.io

blitz.on(ev, fn)

Listens to specific Socket.io event, then runs the given function with the received data

ArgumentDescriptionDefault
evEvent name.None
fnFunction to execute on event triggerNone
blitz.emit(ev, data)

Emits event via Socket.io client to server

ArgumentDescriptionDefault
evEvent name.None
dataData to transmit. Can be any data type.None

License

MIT

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.3.3

6 years ago

0.3.1

6 years ago

0.2.19

6 years ago

0.2.18

6 years ago

0.2.17

7 years ago

0.2.15

7 years ago

0.2.14

7 years ago

0.2.13

7 years ago

0.2.12

7 years ago

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.40

7 years ago

0.0.39

7 years ago

0.0.38

7 years ago

0.0.37

7 years ago

0.0.36

7 years ago

0.0.35

7 years ago

0.0.34

7 years ago

0.0.33

7 years ago

0.0.32

7 years ago

0.0.31

7 years ago

0.0.30

7 years ago

0.0.29

7 years ago

0.0.28

7 years ago

0.0.27

7 years ago

0.0.26

7 years ago

0.0.25

7 years ago

0.0.24

7 years ago

0.0.23

7 years ago

0.0.22

7 years ago

0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.12-0

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago