Couth is a new take on the CouchApp concept (Couch Apps being web applications that
are stored and run completely off CouchDB). It has a specific focus on doing as much
as possible based on as little information as possible, and on making CRUD applications
particularly quick to create with full bells and whistles.

Handle all the Couch configuration, including vhost, rewrites, session, etc so you
don't have to

Generate a form to create and edit the relevant objects, including nice things such
as direct validation or drag and drop reodering of array items.

Generate a client side API to access the CRUD backend easily

Provide various paraphernalia for AngularJS apps

Couth is somewhat opinionated, but not completely. If you are planning to use
AngularJS and Bootstrap
your life will be much easier. But you can use something else instead if you want to do
more of the work yourself.

I am well aware that there are plenty of other CouchApp systems out there. I built this
one because none of them suited me.

During development it can be convenient for your couth application to be re-run
whenever there's a change so that you don't have to constantly return to the
command line while you're tweaking some small detail, and can instead just
hit reload.

Nothing simpler, first, if that's not already the case, just install nodemon:

npm install -g nodemon

And then run it:

nodemon --watch static -e js,css,html app.js

The above will only watch inside the static directory but will take into account
file extensions js, css, and html (the default being just js). You can drop the
--watch to watch everything or you can specify several, and you can add more
file extensions.

The following methods are available for configuration. They all accept a value to set,
and return a value if they no parameter. Otherwise they return this so as to be chainable.

app.deployTo(URL). The URL (including only scheme and hostname) to the deployment endpoint.
There are two important endpoints in Couth: the deployment endpoint and the vhost endpoint, and
it's important to understand the difference. In order to expose nice URLs instead of CouchDB's
own rather ugly ones, we rely on CouchDB's URL rewriting functionality. This means that all
requests to http://vhost/ are internally mapped to http://vhost/yourDB/_design/couth/_rewrite/.
Having nice URLs is great, but once those rewrites have been set up, Couth can no longer
communicate with CouchDB at the vhost endpoint since all the paths it needs to do so have been
rewritten.
This is why the deployment endpoint exists: it is a different hostname mapping to the same
CouchDB instance such that the rewriter is not triggered (the rewriter keys off the hostname).

app.vhost(hostname). The hostname for the vhost endpoint, as explained above. This is the address
at which you want your site to be running.

app.port(integer). The port to use for the deployment endpoint (for the vhost endpoint) it doesn't
matter to Couth).

app.auth({ username: "you", password: "secret" }). Sets the authentication credentials that may
be needed to deploy to CouchDB.

app.db(string). The name of the database you wish to use. This is not user visible and so not
very important. CouchDB can be quite particular about what it accepts here, so you should probably
stick to alphanumerics and begin with a letter.

app.index(path). Sets what accessing the root of the site will show. For instance, if you have
a static file called index.html you can call app.index("index.html") to use that. But it can
equally well be anything at all that you have added to your Couth deployment.

app.webAppRoot(path). If you are developing an app that uses the History API you will want the path
you use with your routing to start with a recognisable prefix so that it can be distinguished from
resources that are meant to be obtained from the server. For instance, the example application sets
app.webAppRoot("/app/") and then uses routes that begin with http://books.dev/app/, e.g.
http://books.dev/app/books. Thanks to this option, if you load the previous URL, Couth will recognise
that this URL is controlled by the web app and will return the index page instead of trying to
find a resource.

app.session(integer). The number of seconds that a user session lasts. CouchDB has this ridiculously
low (10 minutes), Couth ups that to 90 days.

Adds a new rewrite. Both from and to are required paths that are getting rewritten.
If specified, method limits the rewrite to a specific method. If present, query is
an object that provides key/value parameters to be added to the rewritten query (typically
CouchDB view parameters such as include_docs or skip). Note that you do not need this
CouchDB madness of escaping booleans and numbers, Couth does it for you.

Adds a library of code that views, lists, shows, etc. can load using CommonJS and run.
libName is the name of the library (it will be available under lib/ so if you give it a name
of "foo" code can then load it with require("lib/foo")). content is a string pointing to a
file to load, or a Buffer.

Simply accepts a Web Schema. Note however that the
current implementation of the forms generator does not support absolutely all variants (it
supports a lot of them though) so don't go too wild. Also, you want to use the description
field almost systematically since that's what produces the form label.

Sets the permissions on this type. The default is full access to all. The keys of the perms
object can be create, update, or delete (read will be supported before v1.0). The values
can be any of * for access to anyone, logged to required a logged in user, or admin for
a DB admin. The capabilities for these checks will grow.

This contains AngularJS, jQuery, the small parts of jQuery UI needed for drag and drop reordering,
the code to generate JS APIs to the backend and a host of useful code if you're using Angular.
The latter part includes:

The couth-type directive that a form uses to register itself as an editor for a type.

The couth-dnd directive that is used to support drag and drop reordering of items in a model.

The CouthCtrl controller that your application would likely use. This handles setting up the
session so that you know who the user is (if logged in), handling all the login/logout/signup
functionality. It also handles the loading events (to show the loader), error and success
messages, and how to dispatch to the form that supports a given type when it needs to be edited
or created.

The CouthFormCtrl controller that is used on the form. This handles saving, resetting,
and reordering arrays.

The startFrom filter that makes it possible to do pagination of the content.

The CouthSimpleCRUD service which makes it easier to set everything up to support full client-side
CRUD with a single method call (see the example app's client side JS).

Includable pieces of HTML that you can use to trigger the edition of an objection or its deletion
(with built in confirmation). See the example app for usage, the important thing being to
properly assign $couthItem.

Does the grunt work of uploading an attachment. You probably want to call the higher level
methods that deal with static content as this really will only do the upload. It takes the path
at which you want the attachment stored on the design document, the content (path to file or Buffer),
and an optional media type.

Internally, when we process the various commands, everything that needs to make a request
calls this, and it is only when deploy is called that the requests are actually executed
(guaranteed one by one, in order).

The request that is passed is an object with two fields:

run: this is a function that will receive a Cradle instance, and a callback to call once
it's done processing.

In couth/forms is a module with a generate() method that can take a Type and generate an
Angular-friendly form that can create or edit it. This is mostly used internally, but if you're
seeing form problems or limitations that's the place to look.