Potion
A TypeScript client for APIs written in Flask-Potion.
Table of Contents
Installation
Install this package with NPM:
$(node bin)/npm install potion-client
Or Yarn:
yarn install potion-client
It can also be used with JSPM:
$(npm bin)/jspm install potion=npm:potion-client
Usage
Before you use this package, make sure you include reflect-metadata and a shim for ES6/7 features (core-js has the most comprehensive collection of shims and I advise using it).
Furthermore, this package has multiple implementations available, it can be used with:
IMPORTANT: All resource properties that are retrieved from the backend will be converted from snake case to camel case, so the following:
class Foo(db.Model):
bar_name = db.Column(db.String(256), nullable=True)
Will match the following resource on the client side:
class Foo extends Item {
barName: string;
}
Contribute
If you'd like to contribute:
- Clone the repository
git clone https://github.com/biosustain/potion-node
; - Install all the deps
yarn install
/npm install
.
Now you can start hacking :)
Before you make a pull request, you can check if builds and tests will run successfully:
- Run the tests using
npm run test
(if you wish to run tests on file change, use npm run test:continuous
); - Use
npm run build
to build the .ts
files and see if any errors have occurred.
If you're a contributor and you wish to publish the package, use the release scripts from package.json
.
For example, if you wish to publish a patch, use:
npm run release
Note that the master
branch will publish to the latest
tag, whereas the next
branch will publish to the next
tag on NPM.
This can be useful for making pre releases or major changes and allowing users to test the lib,
but not break apps depending on the latest version.
As a rule of thumb, in the next
branch, you should always make a pre release,
allowing for publish the stable version in the master
branch:
npm run release:prerelease
npm run release:premajor
npm run release:prerelease