facades
v1.0.12
Published
Simple abstraction of data-driven methods in a database agnostic way.
Downloads
2
Maintainers
Readme
BlueJayz - Facades
Technology agnostic query framework for building data-driven aplications on node.
[![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] [![Linux Build][travis-image]][travis-url] [![Windows Build][appveyor-image]][appveyor-url] [![Test Coverage][coveralls-image]][coveralls-url]
Site | Docs | Wiki | Contributing
Eco-System dependencies : | Project | Status | Description | |---------|--------|-------------| | Chirp | [![bluejayz-query-status]][bluejayz-query-package] | Query syntax for data-driven API's | | Schemming | [![bluejayz-query-status]][bluejayz-query-package] | Query syntax for data-driven API's |
Eco-System : | Project | Status | Description | |---------|--------|-------------| | Chirp | [![bluejayz-query-status]][bluejayz-query-package] | Query syntax for data-driven API's | | Schemming | [![bluejayz-query-status]][bluejayz-query-package] | Query syntax for data-driven API's | | Chirp | [![bluejayz-query-status]][bluejayz-query-package] | Query syntax for data-driven API's | | Routes | [![bluejayz-query-status]][bluejayz-query-package] | Query syntax for data-driven API's | | Hornbill | [![hornbill-status]][hornbill-package] | Complete security layer for open API's |
Introduction
The name Bluejayz
comes from the Blue-jay bird known for it's exceptional inteligence and complex social structures. During a time we were scaling our technology, a flexible way for us to oragnise our data and logic became very important and the BlueJayz bird came to mind. We built Bluejayz to handle this complexity so that we could focus on building client-centric applications. Our philosophy around our software development is simple:
- separate concerns.
- separate them well.
BlueJayz in only conerned with abstracting your complex technology setup into standard logic for API development.
Installation
Using npm:
$ npm install bluejayz --save
Quick Start
Get started with a BlueJayz node API by copying the code below:
//////////////////////////////////////////////////////////////////////////////////////////////////
//Express Example
//////////////////////////////////////////////////////////////////////////////////////////////////
import * as express from 'express';
import { BlueJayz } from 'bluejayz';
//Create Express Server
let server = express();
//configure your data model
const configuration = {
model : {
name : "testTable"
,schema : {
columnOne : {type : "String" , trim : false , unique : false}
,columnTwo : {type : "String" , trim : false , unique : false}
,columnThree : {type : "String" , trim : false , unique : false}
}
}
}
let Microservice = new BlueJayz(configuration)
Microservice.installApi(server)
server.listen(3000);
//////////////////////////////////////////////////////////////////////////////////////////////////
//Restify Example
//////////////////////////////////////////////////////////////////////////////////////////////////
import * as restify from 'restify';
import { BlueJayz } from 'bluejayz';
//Create restify srver
let server = restify.createServer();
//configure your data model
const configuration = {
engine : "restify"
,model : {
name : "testTable"
,schema : {
columnOne : {type : "String" , trim : false , unique : false}
,columnTwo : {type : "String" , trim : false , unique : false}
,columnThree : {type : "String" , trim : false , unique : false}
}
}
}
let Microservice = new BlueJayz(configuration)
Microservice.installApi(server)
server.listen(3000);
Features
Technology agnostic
, the most common routing methods have already been abstracted and translated to multiple database technologies.Build your own
routing methods and customize your API solution to suit your needs.- Uses a
single query syntax
, (Chirp) for all database instances connected to BlueJayz. - Plays well with both
Express js
andRestify
, two of the most popular node server engines.
Configuration
BlueJayz can be configured to work as required. A complete configuration example looks as follows:
export const configuration = {
engine : "express"
, api : "collection"
, facade : "mongo"
, connection : {
//Either define a full connection string.
string : "mongodb://username:********@localhost:27017/myproject"
//Or define the connection string parameters.
, host : "localhost"
, port : "27017"
, db : "myproject"
, user : "username"
, pass : "********"
//For external API services
,token : "********"
,secret : "*********"
}
, model : {
name : "testTable"
, schema : {/*Database schema*/ }
}
}
Engine
Defines the routing engine for the produced API. Using the installApi
method described here, BlueJayz will mount the router to your server. Currently, there is support for two types.
API
BlueJayz has a list of predefined routing methods to quickly get your application running. You can pass a single api parameter as follows:
api : "collection"
Or an array to include more methods to your router:
api : ["collection" , "graph"]
BlueJayz supports quite a few routing methods and we are always adding more to ease your API development. To get the blueprint of the entire BlueJayz routing universe, check out the complete documentation here
utilities
: A set of standard methods that are included with all predefined api setup.:_column
: Name of column in schema you would like to add an index to.
********************************************
'BlueJayz Utilities API'
********************************************
____________________________________________
| | Path |
--------------------------------------------
| post | /api/v1/bulkimport/ |
--------------------------------------------
| post | /api/v1/import/ |
--------------------------------------------
| post | /api/v1/drop/ |
--------------------------------------------
| post | /api/v1/index?{_column} |
--------------------------------------------
| get | /api/v1/model/ |
--------------------------------------------
collection
: (Default) Produces standard CRUD (Create Read Update Delete) operations on your configured database instance.:_id
: Uniquely generated id using uuid for collection item.
********************************************
'BlueJayz Collection API'
********************************************
____________________________________________
| | Path |
--------------------------------------------
| get | /api/v1/route/ |
--------------------------------------------
| get | /api/v1/route/:_id |
--------------------------------------------
| post | /api/v1/route/ |
--------------------------------------------
| put | /api/v1/route/:_id |
--------------------------------------------
| del | /api/v1/route/:_id |
--------------------------------------------
Facade
BlueJayz creates a generic interface to facilitate interactions with a datasource through a facade
. This is where we translate the api methods into standard database queries for the following technologies:
Note : The database technology selected must already be installed. BlueJayz does not install the database, it leverages a driver to connect and transact with the database.
mongo
: Use the popular NoSql MongoDb database. Find instruction on how to install it here.json
: For a simple json data store. We use lodisk, a lodash powered json local store for quick prototyping.arango
: Use ArangoDb for optimized topological data store. Using this facade allows for methods to be unlocked when using thegraph
api. Find instruction on how to install it here- External API sources: If you would like to take advantage of an already existing API service investment. BlueJayz can integrate them as required. However Bluejayz will only bind the a sinlge "GET" method to the service. Other methods from your service can be bind using the standard
addMiddleware
andmountPath
methods detailed below. - Structured Query Language: BlueJayz uses an ODBC connection to interact with an already installed driver. Please ensure that there is a driver already installed on your machine. Here is an example on how to install a Postgre-SQL driver on unix and windows.
pg-sql
: For Postgres SQL database. See read about the technology heremy-sql
: For MySQL database. See read about the technology herems-sql
: For Microsoft SQL database. See read about the technology herelite-sql
: For SQLite database. See read about the technology hereoracle-sql
: For Oracle database. See read about the technology here
Database Connection
string
host
port
db
user
pass
api-key
api-secret
Model
name
:schema
type
unique
trim
Methods
status
listPaths
addMiddleware
mountPath
installApi
api
Chirp
Contributing
This project is maintained by a community of developers. Contributions are welcome and appreciated. You can find TypeDoc on GitHub; feel free to start an issue or create a pull requests: https://github.com/TypeStrong/typedoc
License
Copyright (c) 2015 Sebastian Lenz. Copyright (c) 2016-2017 TypeDoc Contributors. Licensed under the Apache License 2.0. -->