This document introduces Elefrant, an open source Node.js framework for building scalable APIs. It provides modularity, customizability, authentication, documentation, and other features out of the box. The creator developed it to meet his needs for building real-time, multidevice apps. The framework is currently in version 0.1 but future versions will offer more extensibility through custom components.
7. 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
8. What’s an API?
API = Application Program Interface
Set of Routines, Protocols and Tools
Used by a lot of companies
9. Benefits
Standard communications between App’s
Create App’s in the Cloud
Earn & Save Money
Multidevice
Light App’s
Fast Maintenance
22. 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
23. Controllers
add: {
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
}
}
24. Models
MongoDb + ElasticSearch
Validation in Model Layer
Typical Functionality of models – like CRUD
25. 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
}
37. Real case
Client
API System
Balancer
Elefrant
MongoD
b
Cache
Redis
Elastic
search
38. 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
39. Get Started v0.1
Donwload from Github
https://github.com/Elefrant/elefrant
Install dependencies
npm install
Execute Elefrant
grunt
40. Want to get involved?
Join to Elefrant Code Team!