@keethealth/api-client v0.18.0
Keet Health Node Module Boilerplate
Adatped from Babel Starter Kit
Boilerplate for developing Keet Health modules in Node.js, using:
- ESlint
- Babel
- Rollup
- Jest
- TravisCI
Table of Contents
File Structure
|-- src/ # where the magic happens
|---- index.js # entry file
|-- dist/ # directory for built items
|-- tools/ # build tools
|-- test/ # module tests
|-- bin/ # executables
|-- .env # environment variables
|-- .eslintrc.json # linting rules because messy code hurts my soul
|-- .gitignore # file patterns to not commit, currently configured only for macOS
|-- .travis.yml # Travis CI config file
|-- package.json # node package dependencies
|-- static.json # necessary for client-side routing
|-- yarn.lock # auto generated yarn file, do not touchUpdating for different projects
This module is intended to be a pure node.js boilerplate without dependencies on DOM or other frameworks/libraries. When you need to update this repo to support other libraries in JS (i.e. React), you should create a new branch and make changes there.
Then, clone from that branch:
git checkout -b react
## ...Commit changes
git clone -b react --single-branch https://github.com/keethealth/keet-module-boilerplate.gitQuick Start
Cloning
git clone https://github.com/keethealth/keet-module-boilerplate.git <module-name>
rm -rf .git && git init
git remote add origin <keethealth/module-name.git>
git remote -vInitialization
cd <module-name>
yarn initYarn will ask you a series of questions to edit package.json.
All questions are already answered by the existing package.json, but you will need to change these:
question name (@keethealth/keet-module-boilerplate): <module-name>
question version (0.0.1):
question description (A project template for authoring and publishing Keet Health libraries):
question repository url (keethealth/keet-module-boilerplate): keethealth/<module-name>Install Dependencies & Build
yarn && yarn build
You should now have a dist folder at path/to/module/dist
Development
To link this package:
yarn linkLearn more about this command at https://yarnpkg.com/lang/en/docs/cli/link/
Go to the app you want to test this module with and link this local package:
cd ../<app-name>
yarn link <module-name>This will create a symlink in your project so that it will resolve import '<module-name' using your local project instead of the node_modules folder.
When you are done and would like to test the package on npm, run the following in your app directory:
yarn unlink <module-name>To completely remove the symlink, run the following in the local package directory:
yarn unlinkRun watch to rebuild bundle on changes made instead of running build manually each time:
yarn watchTesting locally
npx babel-node
babel > const Client = require('./src/Client').default
babel > const apiUrl = 'https://api.keetdev.com'
babel > const accessToken = /* put your token here */
babel > const Api = new Client({ apiUrl, getCurrentSession: () => Promise.resolve({ accessToken }) })
babel > Api.profile.read().then(response => { console.log('response', JSON.stringify(response, null, 2)) })Publishing to npm
Build the package:
yarn buildPublish the package to npm:
yarn publish --access publicYou will be prompted to bump the version. Ensure that you follow semantic versioning strictly.
This publishes the package as a public scoped package under the @keethealth scope.
Read more about scoped packages
Available Scripts
In the project directory, you can run:
yarn test
Launches the test runner in the interactive watch mode.
To see test coverage, run yarn test --coverage.
yarn build
Builds the app for production to the dist folder.
Troubleshooting
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago