Giter Site home page Giter Site logo

buzzdb's Introduction

BuzzDB

A RESTful API interface for the BuzzDB data layer

BuzzDB logo


The service stores and retrieves buzzwords as MongoDB documents in the form:

{
    _id: "5324a5613725c5181205bac2",
    verb: "Scale",
    noun: "Scalability",
    adj: "Scalable",
    rand: 0.14155110088177025
}

Buzzwords may be stored with any or all of the three content fields: verb, noun, and adj. The _id and rand fields are generated by the server.

Currently running as a public-facing API accessible at https://buzzdb.net. Note: The API is currently restricted to HTTPS access only.


Setup

  1. Clone the BuzzDB repository on your server

     $ git clone https://github.com/blackmjck/buzzdb.git
    
  2. (not required if connecting to a remote host) Install MongoDB on localhost

  3. (optional) Create database buzz and collection words inside it.

  4. (optional) Populate with test data from the samples provided in mock/buzzwords.js

     $ node insert.js
    
  5. Install dependencies via npm

     $ cd /path/to/buzzDB
     $ npm install
    
  6. Update lib/creds.js with the URL and credentials for your MongoDB connection

  7. Start the service

     $ node server.js
    
  8. Start querying!


Endpoints

GET /words

URL Parameters:

Parameter Description Required? Type Values Default
random Randomize results no Boolean false
perPage Max results per page no Integer 0 (no limit)
page For pagination no Integer 1
required Specify required fields as comma-separated string values no String noun, verb, adj

Sample Request

**GET** /words?perPage=5&required=noun,verb,adj

Sample Response

HTTP Status: 200 - Success

{
    status: "RETRIEVED",
    msg: "",
    response: [
        {
            noun: "Acquisition",
            adj: "Acquisitive",
            verb: "Acquire",
            rand: 0.627527741715312,
            _id: "5324a5613725c5181205ba46"
        },
        {
            noun: "Collaboration",
            adj: "Collaborative",
            verb: "Collaborate",
            rand: 0.9478897654917091,
            _id: "5324a5613725c5181205ba5c"
        },
        {
            noun: "Scalability",
            adj: "Scalable",
            verb: "Scale",
            rand: 0.14155110088177025,
            _id: "5324a5613725c5181205bac2"
        },
        {
            noun: "Strategy",
            adj: "Strategic",
            verb: "Strategize",
            rand: 0.3378112295176834,
            _id: "5324a5613725c5181205bacc"
        },
        {
            noun: "A/B Testing",
            adj: "A/B Tested",
            verb: "A/B Test",
            rand: 0.9927790435031056,
            _id: "5324a5613725c5181205ba43"
        }
    ],
    results: 5
}

GET /word/:id

Sample Request

**GET** /word/5324a5613725c5181205bacc

Sample Response

HTTP Status: 200 - Success

{
    status: "RETRIEVED",
    msg: "",
    response: [
        {
            noun: "Strategy",
            adj: "Strategic",
            verb: "Strategize",
            rand: 0.3378112295176834,
            _id: "5324a5613725c5181205bacc"
        }
    ],
    results: 1
}

POST /word

Message Body Parameters (as JSON)

Parameter Description Required? Type Values Default
noun Noun form No* String
verb Verb form (infinitive) No* String
adj Adjectival form No* String

* Requests must include at least one of: noun, verb, or adj

Sample Request

**POST** /word  (with `Content-Type: application/json`)
{
    "noun": "EER Diagram",
    "verb": "EER Diagram"
}

Sample Response

HTTP Status: 201 - Created

{
    status: "CREATED",
    msg: "",
    response: [
        {
            _id: "5325cfcc95b1c9a410824be7",
            noun: "EER Diagram",
            rand: 0.6104816475417465,
            verb: "EER Diagram"
        }
    ],
    results: 1
}

PUT /word/:id

Message Body Parameters (as JSON)

Parameter Description Required? Type Values Default
noun Noun form No* String
verb Verb form (infinitive) No* String
adj Adjectival form No* String

* Requests must include at least one of: noun, verb, or adj

Sample Request

**PUT** /word/5325cfcc95b1c9a410824be7  (with `Content-Type: application/json`)
{
    "adj": "EER Diagrammed"
}

Sample Response

HTTP Status: 200 - Success

{
    status: "UPDATED",
    msg: "",
    response: [
        {
            _id: "5325cfcc95b1c9a410824be7",
            adj: "EER Diagrammed"
            noun: "EER Diagram",
            rand: 0.6104816475417465,
            verb: "EER Diagram"
        }
    ],
    results: 1
}

DELETE /word/:id

Sample Request

**DELETE** /word/5324a5613725c5181205bacc

Sample Response

HTTP Status: 200 - Success

{
    status: "DELETED",
    msg: "",
    response: [
        {
            noun: "Strategy",
            adj: "Strategic",
            verb: "Strategize",
            rand: 0.3378112295176834,
            _id: "5324a5613725c5181205bacc"
        }
    ],
    results: 1
}

Changelog

  • v0.1.2 Informed release (2014-03-26)
    • Added EJS template support for static views
    • Linked README.md content to root page requests
  • v0.1.1 Remote release (2014-03-17)
    • Added wrapper for local or remote database connections
    • Added credentials storage for configurable database connections
  • v0.1.0 Initial release (2014-03-16)
    • Added connectors for MongoDB on localhost
    • Turned on /word-based endpoints
    • Stubbed out /type and /phrase endpoint sets
    • Set up REST responses

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.