generator-muzzley-manager
v0.2.4
Published
Yeoman generator for muzzley managers.
Downloads
8
Readme
Muzzley manager generator
What is this?
This is a Yeoman Generator that quickly and effortlessly builds a muzzley Thing Manager app structure.
"What is a Thing Manager?" you may ask
Well, you can think of a Thing Manager as a "thing control remote" app that runs in the Muzzley ecosystem.
Installation
First, you need to have Yeoman installed globally. If you don't have it you can run this in your terminal:
npm install -g yo
Then you need to install the muzzley manager generator:
npm install -g generator-muzzley-manager
How to use?
Run this in your terminal
yo muzzley-manager
Questions
When you run the generator it will ask a few questions to generate custom boilerplate for your project. The following questions will be asked:
> What is the name of the device?
Possible answers
Anything you want.
What it does?
- Create a directory with the name of the device, for e.g. if you call it
awesome
, you'll getmanager-awesome/
- Write to multiple files (
config.js
env variables, plugin handlers) the name of your device
> Do you want to use a third-party module for the provider logic?
Note: The generator is asking if there's already an npm module that can handle aspects of your "thing" such as the communication with its cloud.
Possible answers
- Yes
- No
What it does?
If you answer Yes
It will ask the name of this npm module to add to the dependencies in package.json
.
If you answer No
It will ask if you want to build a local npm module, to keep muzzley manager business logic separated from provider business logic.
If you answer Yes
, it will create a a directory in the root of your app directory called provider_module
.
When you finish it will generate the boilerplate and install the dependencies
App structure
You will get a structure similar to this:
- manager-[thing-name]/
- lib/
- interaction/
- models/
- plugins/
- provider/
- production/
- provider_module/
- public/
- test/
- docs/
- index.js
- config.js
- Gruntfile.js
The core dependencies of the generator is the muzzley-idk and muzzley-client. If you don't know what the hell those are, we suggest that you read the documentation of both packages.
The main dependencies that generator installs are the following:
Note: If one of these dependencies doesn't ring a bell, please check them out because you will need to have basic knowledge on what they do and how to use them.
Explaining lib in more detail
First when we talk about provider, we are referring to the manafacturer, and in most cases that person will be you or someone else who is reading this.
When we say, provider business logic, we are referring to the cloud/web service the thing is pushing information to or/and receiving information from.
Interaction
Interactions are full-duplex real-time communication using sockets and the muzzley protocol. You can read more about that here.
Models
This are representations of muzzley business logic and the way information should be stored. You have the following models:
Channel
: This is represents an instance of your thing, it can be a sensor, a piece of hardware, or even you or your cat.Credentials
: Normally, the credentials are represented as an access token that give access to the provider API endpoints.Subscription
: This represents a user/channel relationship.
Plugins
Plugins are isolated pieces of business logic and reusable utilities used in hapi. Read more about plugins here.
Provider
This is a wrapper used to communicate with the http server and the muzzley client, using provider business logic. It also stores and retrieves information from a local thing storage.