41
The Framework for API lovers @elefrantjs

Elefrant [ng-Poznan]

Embed Size (px)

DESCRIPTION

Beta version presentation in Ng-Poznan (Sept 2014) of Elefrant, the Framework for API lovers

Citation preview

Page 1: Elefrant [ng-Poznan]

The Framework for API lovers

@elefrantjs

Page 2: Elefrant [ng-Poznan]

About me

Marcos Sanz Latorre

@marsanla

IT. Engineer

I’m Spanish

Denmark, USA, Poland

Love Basketball & Coding

Page 3: Elefrant [ng-Poznan]

About me

Created 13Genius (Group of friends)

App Twitter, Elefrant, Meetk.at, Fantity

I quit my stable job, to follow my dream

Page 4: Elefrant [ng-Poznan]

My Team

Page 5: Elefrant [ng-Poznan]

A bit of background…

We love to develop our ideas

Start Meetk.at project

Page 6: Elefrant [ng-Poznan]

Needs

Multidevice system - API

Modern language

Scalable

Page 7: Elefrant [ng-Poznan]

Technology

NodeJs :

– Fast and easy (Javascript)

– We can use for everything

– XMPP, Reverse Ajax, Websockets, Server-sent Events, Long

Polling, Flash Sockets…

– Native bindings

We want a Realtime app

Page 8: Elefrant [ng-Poznan]

What’s an API?

API = Application Program Interface

Set of Routines, Protocols and Tools

Used by a lot of companies

Page 9: Elefrant [ng-Poznan]

Benefits

Standard communications between App’s

Create App’s in the Cloud

Earn & Save Money

Multidevice

Light App’s

Fast Maintenance

Page 10: Elefrant [ng-Poznan]

In the market…

Page 11: Elefrant [ng-Poznan]

We wanted…

Just an API Framework Server

Light and Simple

Modulable

Page 12: Elefrant [ng-Poznan]

So…

had borned!

Page 13: Elefrant [ng-Poznan]

Elefrant

NodeJs Framework to create API servers

HMC

(Model & Controller modulable)

Restify based

Fast & Easy

Light

Open source

Page 14: Elefrant [ng-Poznan]

Features

Modulable & Customizable

Scalable + Cluster

Events

Socket, HTTP

Auto Documentation

Authentication Basic & 2.0

Page 15: Elefrant [ng-Poznan]

Features

Validation

Rate Limit controller

ORM Waterline

Audit & Logger

Custom Errors

Cache

Page 16: Elefrant [ng-Poznan]

Pros

Simple

Authentication

Documentation

Fast

Architecture

Versionable

Page 17: Elefrant [ng-Poznan]

Framework

Elefrant

Balancer

Websockets

http/Ajax

Cache

Db3rd

Services

Actions

Pub/Sub

Components

Core

Page 18: Elefrant [ng-Poznan]

Who’s using…

Health and Nutrition Startup

Security and Biometric Software

Own projects

Page 19: Elefrant [ng-Poznan]

Current Version

Version 0.1

We have just started

but we have a great future

Page 20: Elefrant [ng-Poznan]

v 0.1 (Current)

Core

Models

Controllers (API versions)

Config

Routes

Env

Page 21: Elefrant [ng-Poznan]

Init

Core

Models

Controllers (API versions)

Config

Routes

Env

1 2

3

4

5

6

Page 22: Elefrant [ng-Poznan]

Controllers

Versions of API’s

https://api.acme.com/v1/products

https://api.acme.com/v2/products

Validation of params from path, body, query

Documentation

Functionality of the actions

Page 23: Elefrant [ng-Poznan]

Controllersadd: {

spec: {

summary: 'Return a list of users, filtered by parameters’,

….

},

validation: {

email: {

isRequired: true,

isEmail: true,

scope: 'body’,

description: ''

},

},

action: function (req, res, next) {

// Functionality

}

}

Page 24: Elefrant [ng-Poznan]

Models

MongoDb + ElasticSearch

Validation in Model Layer

Typical Functionality of models – like CRUD

Page 25: Elefrant [ng-Poznan]

Routing

Auto generate route from:

{

name: 'nameforroute',

path: 'url/of/the/route',

method: 'GET or POST or PUT or DELETE or PATCH',

version: [

'1.0.0',

’2.0.1'

],

auth: true or false,

scopes: [

'scopeItem',

'scopeItem'

],

action: api.v1.nameController.method

}

Page 26: Elefrant [ng-Poznan]

Config

All enviroments variables

-Config

- Env

- Production- Database.js

- …

- Test- …

- Development- Database.js

- …

- Redis.js

- Database.js

- Session.js

- Logger.js

- …

module.exports = {

host: 'localhost',

port: '27017',

database: 'elefrant'

};

Access:

config.database.host

Page 27: Elefrant [ng-Poznan]

Integrations

Task

automator

Continuous

Integration

Page 28: Elefrant [ng-Poznan]

v 0.2

Core

Components

Actions (API versions)

Config Env

Default

Components

Page 29: Elefrant [ng-Poznan]

v 0.2

Core

Components

Actions (API versions)

Config Env

Default

Components

1 2 3

45

6

Page 30: Elefrant [ng-Poznan]

Features

+ features v 0.1

More control

Develop your own components

Open ocean of possibilities

Page 31: Elefrant [ng-Poznan]

Components

Config

Particles.json

Components, modules or plugins

Example: oauth2.0, logger, response, audit, elasticSearch, …

nameOfComp.js

Lib

Whatever you need…

Page 32: Elefrant [ng-Poznan]

ComponentsParticles.json – (Variables to define the component)

Example of component index:

module.exports = function(config, logger) {

return {

start: function() {

http.createServer(app).listen(config.server.port, function

() {

logger(‘Server listening on' +

config.server.port);

});

}

};

};

module.exports.__module = {

args: [”config", ”logger”]

};

Page 33: Elefrant [ng-Poznan]

Actions

Models

ControllersConfig

Env

Routes

Group of actions for API

Example: Users, Settings, Tweets, Favourites, …

Page 34: Elefrant [ng-Poznan]

Integrations

Page 35: Elefrant [ng-Poznan]

Release v. 0.2

End October 2014

Page 36: Elefrant [ng-Poznan]

Future features

Game server Modules

Mailer

Background Tasks

PubSub

TCP

Hooks

Page 37: Elefrant [ng-Poznan]

Real case

Client

Elefrant

Balancer

MongoD

bCache

Redis

API System

Elastic

search

Page 38: Elefrant [ng-Poznan]

Response Times

Ram: 512 MB

Processor: 1 Core

SSD: 20 GB

Tranfer: 1 Tb

Request:

Search items in mongoDb using

ElasticSearch

First call 84 ms

Next calls 4-15 ms

Con. Conex. ≤500

Page 39: Elefrant [ng-Poznan]

Get Started v0.1

Donwload from Github

https://github.com/Elefrant/elefrant

Install dependencies

npm install

Execute Elefrant

grunt

Page 40: Elefrant [ng-Poznan]

Join to Elefrant Code Team!

Want to get involved?

Page 41: Elefrant [ng-Poznan]

www.elefrant.com

[email protected]

Thank you!!

@elefrantjs @marsanla