Upload
marcos-latorre
View
334
Download
0
Embed Size (px)
DESCRIPTION
Beta version presentation in Ng-Poznan (Sept 2014) of Elefrant, the Framework for API lovers
Citation preview
The Framework for API lovers
@elefrantjs
About me
Marcos Sanz Latorre
@marsanla
IT. Engineer
I’m Spanish
Denmark, USA, Poland
Love Basketball & Coding
About me
Created 13Genius (Group of friends)
App Twitter, Elefrant, Meetk.at, Fantity
I quit my stable job, to follow my dream
My Team
A bit of background…
We love to develop our ideas
Start Meetk.at project
Needs
Multidevice system - API
Modern language
Scalable
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
What’s an API?
API = Application Program Interface
Set of Routines, Protocols and Tools
Used by a lot of companies
Benefits
Standard communications between App’s
Create App’s in the Cloud
Earn & Save Money
Multidevice
Light App’s
Fast Maintenance
In the market…
We wanted…
Just an API Framework Server
Light and Simple
Modulable
So…
had borned!
Elefrant
NodeJs Framework to create API servers
HMC
(Model & Controller modulable)
Restify based
Fast & Easy
Light
Open source
Features
Modulable & Customizable
Scalable + Cluster
Events
Socket, HTTP
Auto Documentation
Authentication Basic & 2.0
Features
Validation
Rate Limit controller
ORM Waterline
Audit & Logger
Custom Errors
Cache
Pros
Simple
Authentication
Documentation
Fast
Architecture
Versionable
Framework
Elefrant
Balancer
Websockets
http/Ajax
Cache
Db3rd
Services
Actions
Pub/Sub
Components
Core
Who’s using…
Health and Nutrition Startup
Security and Biometric Software
Own projects
Current Version
Version 0.1
We have just started
but we have a great future
v 0.1 (Current)
Core
Models
Controllers (API versions)
Config
Routes
Env
Init
Core
Models
Controllers (API versions)
Config
Routes
Env
1 2
3
4
5
6
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
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
}
}
Models
MongoDb + ElasticSearch
Validation in Model Layer
Typical Functionality of models – like CRUD
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
}
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
Integrations
Task
automator
Continuous
Integration
v 0.2
Core
Components
Actions (API versions)
Config Env
Default
Components
v 0.2
Core
Components
Actions (API versions)
Config Env
Default
Components
1 2 3
45
6
Features
+ features v 0.1
More control
Develop your own components
Open ocean of possibilities
…
Components
Config
Particles.json
Components, modules or plugins
Example: oauth2.0, logger, response, audit, elasticSearch, …
nameOfComp.js
Lib
Whatever you need…
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”]
};
Actions
Models
ControllersConfig
Env
Routes
Group of actions for API
Example: Users, Settings, Tweets, Favourites, …
Integrations
Release v. 0.2
End October 2014
Future features
Game server Modules
Mailer
Background Tasks
PubSub
TCP
Hooks
…
Real case
Client
Elefrant
Balancer
MongoD
bCache
Redis
API System
Elastic
search
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
Get Started v0.1
Donwload from Github
https://github.com/Elefrant/elefrant
Install dependencies
npm install
Execute Elefrant
grunt
Join to Elefrant Code Team!
Want to get involved?