Simple abstraction of data-driven methods in a database agnostic way.
npm install facadesBluejayz 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:
1. separate concerns.
2. separate them well.
BlueJayz in only conerned with abstracting your complex technology setup into standard logic for API development.
Installation
Using npm:
`shell
$ npm install bluejayz --save
`
Quick Start
Get started with a BlueJayz node API by copying the code below:
`js
//////////////////////////////////////////////////////////////////////////////////////////////////
//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 and Restify, two of the most popular node server engines.
Configuration
BlueJayz can be configured to work as required. A complete configuration example looks as follows:
`js
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/ }
}
}
`
$3
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.
* express: The popular Express routing engine.
* restify: The popular Restify routing engine.
$3
BlueJayz has a list of predefined routing methods to quickly get your application running. You can pass a single api parameter as follows:
`js
api : "collection"
`
Or an array to include more methods to your router:
`js
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.
`shell
**
'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.
`shell
**
'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 |
--------------------------------------------
`
$3
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 the graph 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 and mountPath methods detailed below.
* soap: For the popular xml based soap service.
* rest: To interact with an already build RESTful service.
* 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 here
* my-sql: For MySQL database. See read about the technology here
* ms-sql: For Microsoft SQL database. See read about the technology here
* lite-sql: For SQLite database. See read about the technology here
* oracle-sql: For Oracle database. See read about the technology here
$3
* string
* host
* port
* db
* user
* pass
* api-key
* api-secret
$3
* name:
* schema
* type
* unique
* trim`