Giter VIP home page Giter VIP logo

hoodie's Introduction

hoodie

A generic backend with a client API for Offline First applications

Build Status Coverage Status Dependency Status devDependency Status

The Low-Profile Dog Hoodie Mascot

Hoodie lets you build apps without thinking about the backend and makes sure that they work great independent from connectivity.

This is Hoodie’s main repository. It starts a server and serves the client API. Read more about how the Hoodie server works.

A good place to start is our Tracker App. You can play around with Hoodie’s APIs in the browser console and see how it works all together in its simple HTML & JavaScript code.

If you have any questions come say hi in our chat.

Setup

Hoodie is a Node.js package. You need Node Version 4 or higher and npm Version 2 or higher, check your installed version with node -v and npm -v.

First, create a folder and a package.json file

mkdir my-app
cd my-app
npm init -y

Next install hoodie and save it as dependency

npm install --save hoodie

Now simply use npm start to start up your Hoodie app!

You can find a more thorough description in our Getting Started Guide.

Usage

hoodie can be used as as CLI (Command Line Interface) or as hapi plugin. The options are slightly different, see below

CLI

Once you finished the setup, you can start your hoodie server with

npm start

To pass CLI options to Hoodie, you have to separate them with --, for example:

npm start -- --port=8090 --inMemory

Available CLI options are

option default description
--address '127.0.0.1' Address to which Hoodie binds
--data '.hoodie' Data path
--dbUrl If provided, uses external CouchDB. URL has to contain credentials.
--loglevel 'warn' One of: silent, error, warn, http, info, verbose, silly
-m, --inMemory false Whether to start the PouchDB Server in memory
--port 8080 Port-number to run the Hoodie App on
--public 'public' path to static assets
--url - Optional: external URL at which Hoodie Server is accessible (e.g. http://myhoodieapp.com)
-h, --help, --usage - Prints help and available options
-v, --version - Shows Hoodie version

Hoodie CLI is using rc for configuration, so the same options can be set with environment variables and config files. Environment variables are prefixed with hoodie_. Examples: hoodie_port=8090 or hoodie_inMemory=true. Configuration files can be in INI or JSON format and can be placed at different locations. Most commonly you would place a .hoodierc file in your app’s directory, and it can look like this

{
  port: 8090,
  inMemory: true
}

The priority of configuration:

  1. command line arguments
  2. Environment variables
  3. .hoodierc files
  4. Your app’s defaults form "hoodie" key in "package.json"
  5. Hoodie’s defaults as shown in table above

hapi plugin

You can load hoodie as hapi plugin to use it in your existing hapi application:

var Hapi = require('hapi')
var hoodie = require('hoodie').register

var server = new Hapi.Server()
server.connection({
  host: 'localhost',
  port: 8000
})

server.register({
  register: hoodie,
  options: { // pass options here
    inMemory: true,
    public: 'dist'
  }
}, function (error) {
  if (error) {
    throw error
  }

  server.start(function (error) {
    if (error) {
      throw error
    }

    console.log(('Server running at:', server.info.uri)
  })
})

The available options are

option default description
paths.data '.hoodie' Data path
paths.public 'public' Public path
db PouchDB options
inMemory false If set to true, configuration and other files will not be read from / written to the file system
client {} Hoodie Client options. client.url is set based on hapi’s server.info.host
account {} Hoodie Account Server options. account.admins, account.secret and account.usersDb are set based on db option above.
store {} Hoodie Store Server options. store.couchdb, store.PouchDB are set based on db option above. store.hooks.onPreAuth is set to bind user authentication for Hoodie Account to Hoodie Store.

Testing

Local setup

git clone https://github.com/hoodiehq/hoodie.git
cd hoodie
npm install

The hoodie test suite is run with npm test. You can read more about testing Hoodie.

You can start hoodie for itself using npm start. It will serve the contents of the public folder.

Backers

Become a backer and show your Hoodie support!

Official Sponsors

Show your support for Hoodie and help us sustain our inclusive community. We will publicly appreciate your support and are happy to get your word out, as long as it aligns with our Code of Conduct.

License

Apache 2.0

hoodie's People

Contributors

acconut avatar allain avatar amilajack avatar arcadiusk avatar bbn avatar benwhite-deltas avatar boennemann avatar brunopedroso avatar capellini avatar cflatts avatar christophwitzko avatar courajs avatar dar5hak avatar espy avatar gr2m avatar greenkeeper[bot] avatar greenkeeperio-bot avatar guria avatar jameswestnz avatar janl avatar klazich avatar lupomontero avatar mbad0la avatar michielbdejong avatar nintra avatar redice44 avatar rmehner avatar rogeriochaves avatar svnlto avatar timblack1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.