Skip to content

Latest commit

 

History

History
 
 

server

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

back to hoodie

hoodie/server

After installing hoodie, npm start will run bin/start.js which reads out configuration from all the different places using the rc package, then passes it as options to getHoodieServer, the main function returned by this package, defined in server/index.js.

Hoodie is built on Hapi.

In getHoodieServer the passed options are amended with defaults and parsed into configuration for the Hapi server and the core modules (see architecture). For example, hoodie-account-server and hoodie-store-server require different options, which are extracted from options and stored in config.account and config.store respectively.

Hoodie uses CouchDB for data persistence and authentication. If options.dbUrl is not set, it falls back to PouchDB.

Once all configuration is taken care of, the internal plugins are initialised (see server/plugins/index.js). We define simple Hapi plugins for logging and for serving the app’s public assets and the Hoodie client. We also load the core modules and register them with the Hapi server.

Once everything is setup, getHoodieServer runs the callback and passes the Hapi server instance. The server is then started at the end of bin/start.js and the URL where hoodie is running is logged to the terminal.

Architecture

Hoodie is a server built on top of hapi with frontend APIs for account and store related tasks.

  1. account :octocat: Build Status Dependency Status

    Hoodie’s account core module. It combines account-client, account-server and exposes a generic account UI.

    1. account-server :octocat: Build Status Coverage Status Dependency Status

      Hapi plugin that implements the Account JSON API routes and exposes a corresponding API at server.plugins.account.api.*, persisting user accounts using PouchDB.

    2. account-client :octocat: Build Status Coverage Status Dependency Status

      see below

  2. store :octocat: Build Status Dependency Status

    Hoodie’s store core module. It combines store-client, store-server and exposes a generic store UI.

    1. store-server :octocat: Build Status Coverage Status Dependency Status

      Hapi plugin that implements CouchDB’s Document API. Compatible with CouchDB and PouchDB for persistence.

    2. store-client :octocat: Build Status Coverage Status Dependency Status

      see below

  3. client :octocat: Build Status Coverage Status Dependency Status

    Hoodie’s front-end client for the browser. It integrates Hoodie’s client core modules: account-client, store-client, connection-status and log

    1. account-client :octocat: Build Status Coverage Status Dependency Status

      Client for the Account JSON API. It persists session information in localStorage and provides front-end friendly APIs for things like creating a user account, confirming, resetting a password, changing profile information, or closing the account.

    2. store-client :octocat: Build Status Coverage Status Dependency Status

      Store client for data persistence and offline sync. It combines pouchdb-hoodie-api and pouchdb-hoodie-sync. It adds a few other methods like .isPersistent() or .hasLocalChanges() and a scoped store API.

      1. pouchdb-hoodie-api :octocat: Build Status Coverage Status Dependency Status

        PouchDB plugin that provides simple methods to add, find, update and remove data.

      2. pouchdb-hoodie-sync :octocat: Build Status Coverage Status Dependency Status

        PouchDB plugin that provides simple methods to keep two databases in sync.

    3. connection-status :octocat: Build Status Coverage Status Dependency Status

      Browser library to monitor a connection status. It emits disconnect & reconnect events if the request status changes and persists its status in localStorage.

    4. log :octocat: Build Status Coverage Status Dependency Status

      JavaScript library for logging to the browser console. If available, it takes advantage of CSS-based styling of console log outputs.

  4. admin :octocat: Build Status Dependency Status

    Hoodie’s built-in Admin Dashboard, built with Ember.js

    1. admin-client :octocat: Build Status Coverage Status Dependency Status

      Hoodie’s front-end admin client for the browser. Used in the Admin Dashboard, but can also be used standalone for custom admin dashboard.