micro-wishes
Core library for building Wishes microservices.
What is a Wishes microservice?
In short: an easily-deployable HTTP microservice for collecting user feedback about your apps.
Installation
Requires Node>=7.
npm install micro-wishes --save
# OR
yarn add micro-wishes
Usage
The micro-wishes
function is the only public API. It takes a backend function which contains the code user feedback (e.g. post a GitHub issue, send an email). The second argument, attributes
, is an Object
that describes the backend (e.g. name
, version
, description
).
The first argument to the backend function is the parsed client input which will contain--at a minimum--an entry named body
with the feedback content. The backend function also receives the request (req
) and response (res
) objects. See the micro docs for more information about these objects.
The micro-wishes
function returns a micro request handler.
// index.jsconst createError = ;const wishes = ;const sendEmail = ; const EmailBackend = async { const email = processenvFEEDBACK_EMAIL; // where to receive feedback const subject = `[wishes] Feedback from `; const content = ` posted feedback on your app: Cheers,The Wishes Robot`; try const result = await ; return status: resultstatus ; catch err throw 400 'Could not send email' err; }; moduleexports = ;
The service can then be run with the micro
CLI via npm start
.
npm start
Backends
Development
- Fork and clone this repo.
cd
into the project directory. yarn install
- To run tests:
npm test
- To run the example server with auto-reloading:
npm run dev
Debugging in tests with iron-node
Add debugger
statements, then run the following:
yarn global add iron-node
npm run test:debug
License
MIT Licensed.