GithubHelp home page GithubHelp logo

lienhoodie / hoodie-store-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hoodiehq/hoodie-store-server

0.0 0.0 0.0 62 KB

:dog: CouchDB APIs for storing JSON data and sync

License: Apache License 2.0

JavaScript 100.00%

hoodie-store-server's Introduction

hoodie-store-server

CouchDB API for data persistence and offline sync

Build Status Coverage Status Dependency Status devDependency Status

hoodie-store-server is a Hapi plugin that implements CouchDB’s Document API and exposes a JavaScript API to manage databases, access and replications.

Example

var Hapi = require('hapi')
var hoodieStore = require('@hoodie/store-server')
var PouchDB = require('pouchdb')

var server = new Hapi.Server()

server.connection({
  port: 8000
})

server.register({
  register: hoodieStore,
  options: {
    PouchDB: PouchDB
  }
}, function (error) {
  if (error) throw error
})


server.start(function () {
  console.log('Server running at %s', server.info.uri)
})

Options

options.PouchDB

PouchDB constructor. Required

options: {
  PouchDB: require('pouchdb-core').plugin('pouchdb-adapter-leveldb')
}

If you want connect to a CouchDB, use the pouchdb-adapter-http and set options.prefix to the CouchDB url. All requests will be proxied to CouchDB directly, the PouchDB constructor is only used for server.plugins.store.api

options: {
  PouchDB: require('pouchdb-core')
    .plugin('pouchdb-adapter-http')
    .defaults({
      prefix: 'http://localhost:5984',
      auth: {
        username: 'admin',
        password: 'secret'
      }
    })
}

options.hooks

Route lifecycle hooks. Optional

options: {
  hooks: {
    onPreResponse: onPreResponseHandler,
    onPreAuth: onPreAuthHandler,
    onPostAuth: onPostAuthHandler,
    onPreHandler: onPreHandlerHandler,
    onPostHandler: onPostHandlerHandler,
    onPreResponse: onPreResponseHandler
  }
}

See http://hapijs.com/api#request-lifecycle for more information

Testing

Local setup

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

Run all tests and code style checks

npm test

Contributing

Have a look at the Hoodie project's contribution guidelines. If you want to hang out you can join our Hoodie Community Chat.

License

Apache 2.0

hoodie-store-server's People

Contributors

gr2m avatar greenkeeperio-bot avatar finnp avatar christophwitzko avatar minrwhite avatar konson avatar jameswestnz avatar boennemann avatar derwin4o 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.