Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
andriykhc committed Sep 10, 2022
1 parent ac0bef3 commit cb39297
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
quote_type = single

[*.yml]
indent_style = space
indent_size = 2

[vcbuild.bat]
end_of_line = crlf

[Makefile]
indent_size = 8
indent_style = tab

[{deps}/**]
charset = unset
end_of_line = unset
indent_size = unset
indent_style = unset
trim_trailing_whitespace = unset

[{test/fixtures,deps,tools/node_modules,tools/gyp,tools/icu,tools/msvs}/**]
insert_final_newline = false
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Publish to NPM

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: '14.x'
cache: 'npm'
registry-url: https://registry.npmjs.org/

- name: Install dependencies and build
run: npm ci && npm run build

- name: Publish package on NPM 📦
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
54 changes: 52 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# botika-socket-http-node
Node.js client to interact with the Botika Socket REST API
# Botika Socket HTTP Node Library

Node.js library for interacting with the Botika Socket HTTP API.

## Installation

You can get the Botika Socket PHP library via a npm package called `botika-socket`. See <https://www.npmjs.com/package/botika-socket>

```bash
npm i botika-socket
```

## Botika Socket constructor

Use the credentials from your Botika Socket application to create a new instance.

```javascript
import { Socket, Auth } from 'botika-socket';
const baseURL = 'https://socket.example.com';
const auth = new Auth('username', 'password');

// Initialize socket
const socket = new Socket(baseURL, auth);
```

## Logging configuration

```javascript
const logger = require('pino')()

socket.setLogger(logger);
```

## Publishing/Triggering events

To trigger an event on one or more channels use the `trigger` function.

### A single channel

```javascript
// Options get from https://axios-http.com/docs/req_config
const options = {};
socket.trigger('my-channel', 'my_event', 'hello world', options);
```

### Multiple channels

```javascript
// Options get from https://axios-http.com/docs/req_config
const options = {};
socket.trigger([ 'channel-1', 'channel-2' ], 'my_event', 'hello world', options);
```
157 changes: 155 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cb39297

Please sign in to comment.