Skip to content

Wendly/openvpn-sdk.js

Repository files navigation

Openvpn SDK for JavaScript

CircleCI

Usage

import OpenVpn from 'openvpn';

const openVpn = new OpenVpn(baseUrl);
openVpn.login(username, password)
    .flatMap(cookie => openVpn.getCurrentUsers(cookie)).subscribe(users => {
        console.log(users);
    }, err => {
        console.error(err);
    });

Installation

yarn add git+ssh://git@github.com/Wendly/openvpn-sdk.js.git#dist

and also you can install specific commit of dist:

yarn add git+ssh://git@github.com/Wendly/openvpn-sdk.js.git#<commit-id>

or

yarn add openvpn-sdk # in progress

Development

  • Please deploy after implemented feature

Deployment

  • git checkout dist && git merge master
  • yarn deploy

Testing and coverage

export OPENVPN_BASE_URL=""
export OPENVPN_USER_NAME=""
export OPENVPN_PASSWORD=""
yarn build && yarn test && yarn coverage

You can open flow-coverage/ and coverage/lcov-report to see

Requirements

  • node
  • yarn
brew install node yarn

Build

p.s. We used babel as default compiler before, you can also use flow-remove-types

yarn install && yarn build && yarn test

Type checking with flow

yarn run flow

You should install a flow plugin on your IDE instead.

API Documentation

yarn docs

You can open docs/ to see

Stack

  • ES6

  • Functional

  • Promise and Rx

  • Type-safety

  • Null-safety

  • Generic

  • Unit testable / coverage report

  • package manager: yarn (npm)

  • http client: axios (request, node-fetch)

  • axios wrapped rx

  • static type checking: facebook/flow (Microsoft/TypeScript, Google/Dart, kotlin2javascript)

  • runtime type checking: codemix/flow-runtime (tcomb)

  • testing frameworks: jest (mocha, karma, jasmine)

  • mock web: nock

Why JavaScript+Flow

I considered that Python, KotlinScript, GoLang, JavaScript, Dart, TypeScript, JavaScript+Flow, Rust, Ruby, OCaml, ReasonML. I choose JavaScript+Flow, because it's type-safety, null-safety, supports generics and functional.

  • Flow: facebook/flow compile-time type checking system
  • +flow-runtime (relacement of tcomb)

Python has PEP 484 decorator/annotation feature that could be able to do type checking But I realized that there is nobody care about that too much in the Python community. There is not too much activity.

And it shouldn't be as decorator for type checking, it should be real type/class for type checking with Generic and Null-Safety. Actually I really want to write KotlinScript, but it's not ready for our teammates.

About

Openvpn SDK for JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published