elefrant [ng-poznan]
DESCRIPTION
Beta version presentation in Ng-Poznan (Sept 2014) of Elefrant, the Framework for API loversTRANSCRIPT
![Page 1: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/1.jpg)
The Framework for API lovers
@elefrantjs
![Page 2: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/2.jpg)
About me
Marcos Sanz Latorre
@marsanla
IT. Engineer
I’m Spanish
Denmark, USA, Poland
Love Basketball & Coding
![Page 3: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/3.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/4.jpg)
My Team
![Page 5: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/5.jpg)
A bit of background…
We love to develop our ideas
Start Meetk.at project
![Page 6: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/6.jpg)
Needs
Multidevice system - API
Modern language
Scalable
![Page 7: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/7.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/8.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/9.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/10.jpg)
In the market…
![Page 11: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/11.jpg)
We wanted…
Just an API Framework Server
Light and Simple
Modulable
![Page 12: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/12.jpg)
So…
had borned!
![Page 13: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/13.jpg)
Elefrant
NodeJs Framework to create API servers
HMC
(Model & Controller modulable)
Restify based
Fast & Easy
Light
Open source
![Page 14: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/14.jpg)
Features
Modulable & Customizable
Scalable + Cluster
Events
Socket, HTTP
Auto Documentation
Authentication Basic & 2.0
![Page 15: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/15.jpg)
Features
Validation
Rate Limit controller
ORM Waterline
Audit & Logger
Custom Errors
Cache
![Page 16: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/16.jpg)
Pros
Simple
Authentication
Documentation
Fast
Architecture
Versionable
![Page 17: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/17.jpg)
Framework
Elefrant
Balancer
Websockets
http/Ajax
Cache
Db3rd
Services
Actions
Pub/Sub
Components
Core
![Page 18: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/18.jpg)
Who’s using…
Health and Nutrition Startup
Security and Biometric Software
Own projects
![Page 19: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/19.jpg)
Current Version
Version 0.1
We have just started
but we have a great future
![Page 20: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/20.jpg)
v 0.1 (Current)
Core
Models
Controllers (API versions)
Config
Routes
Env
![Page 21: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/21.jpg)
Init
Core
Models
Controllers (API versions)
Config
Routes
Env
1 2
3
4
5
6
![Page 22: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/22.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/23.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/24.jpg)
Models
MongoDb + ElasticSearch
Validation in Model Layer
Typical Functionality of models – like CRUD
![Page 25: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/25.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/26.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/27.jpg)
Integrations
Task
automator
Continuous
Integration
![Page 28: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/28.jpg)
v 0.2
Core
Components
Actions (API versions)
Config Env
Default
Components
![Page 29: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/29.jpg)
v 0.2
Core
Components
Actions (API versions)
Config Env
Default
Components
1 2 3
45
6
![Page 30: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/30.jpg)
Features
+ features v 0.1
More control
Develop your own components
Open ocean of possibilities
…
![Page 31: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/31.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/32.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/33.jpg)
Actions
Models
ControllersConfig
Env
Routes
Group of actions for API
Example: Users, Settings, Tweets, Favourites, …
![Page 34: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/34.jpg)
Integrations
![Page 35: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/35.jpg)
Release v. 0.2
End October 2014
![Page 36: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/36.jpg)
Future features
Game server Modules
Mailer
Background Tasks
PubSub
TCP
Hooks
…
![Page 37: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/37.jpg)
Real case
Client
Elefrant
Balancer
MongoD
bCache
Redis
API System
Elastic
search
![Page 38: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/38.jpg)
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]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/39.jpg)
Get Started v0.1
Donwload from Github
https://github.com/Elefrant/elefrant
Install dependencies
npm install
Execute Elefrant
grunt
![Page 40: Elefrant [ng-Poznan]](https://reader033.vdocument.in/reader033/viewer/2022052908/559702181a28ab624f8b45b0/html5/thumbnails/40.jpg)
Join to Elefrant Code Team!
Want to get involved?