Upload
sencha
View
124
Download
0
Embed Size (px)
Citation preview
LinkRest — Modern RESTful API Framework for ExtJS Apps
Rouslan Zenetl, Director of App Development, NHL
Q & A
#LinkRest
The Problem
APIs
APIs
APIs
RESTful APIs
API attendants
“Is It Worth It?” Toxicity
The Solution
Skip the middleman
No more API attendants
Win-win
What is LinkRest?
LinkRestWhat is it?• . . .a protocol- fully compatible with Ext.data.proxy.Rest
• . . .an implementation of the protocol- extensible
LinkRest Stack
Data StorageJDBC, NoSQL, more..
LinkRest Stack
ORMCayenne, POJO, more..
Data StorageJDBC, NoSQL, more..
LinkRest Stack
LinkRest
ORMCayenne, POJO, more..
Data StorageJDBC, NoSQL, more..
LinkRest
ORMCayenne, POJO, more..
Data StorageJDBC, NoSQL, more..
ExtJS
App
licat
ion
Clie
nt
LinkRestWhat it is not?• . . .not a comprehensive application framework (not Spring or Rails)
• . . .not a complete application server
• . . .not an immediate replacement for any of your existing frameworks
LinkRest Stack
LinkRest
ORMCayenne, POJO, more..
Data StorageJDBC, NoSQL, more..
LinkRest Coexists
LinkRest
ORMCayenne, POJO, more..
Data StorageJDBC, NoSQL, more..
Existing APIs
LinkRestFactoids• LinkRest is a project commissioned and open sourced by NHL under Apache 2.0
license
• It was conceived specifically as the server-side counterpart to ExtJS
• First released on May 15, 2014
• Hosted on github.com/nhl/link-rest
• Current version is 2.2
• 60+ apps in production
CompatibilityCayenne ORM, JDBC• DBs supported by Cayenne- DB2, Derby, FireBird, FrontBase, HSQLDB,
H2, Ingres, MySQL, Oracle (10i, 8, 8i, 9i), PostgreSQL (7.4, 8.*), SQLite 3.*, SQLServer, Sybase
• Alternative ORMs possible
• ORM-free is also supported (POJO)- transient objects, e.g. session, status, etc.
LinkRest
ORMCayenne, POJO, more..
Data StorageJDBC, NoSQL, more..
Basic LinkRest
# Create a model (or a batch)POST http://localhost/senchacon/rest/team
# Update a modelPUT http://localhost/senchacon/rest/team/42
# Delete a modelDELETE http://localhost/senchacon/rest/team/42
# Get a single modelGET http://localhost/senchacon/rest/team/42
# Get a collection of modelsGET http://localhost/senchacon/rest/team
# Get a sorted collection of modelsGET http://localhost/senchacon/rest/team?sort=abbrev
Ext.data.proxy.Rest Support
• CRUD
• batchActions:true supported
• Paging (start/limit)
• Sorting
• Autocomplete (combo query)
• Filtering (operator, disabled)
Demo DB Schema
Demo DB SchemaWe’ll use this simple database for demos today (NOT REAL DATA)
package com.nhl.senchacon.rest;
@Path("team")@Produces(MediaType.APPLICATION_JSON)public class TeamResource { @Context private Configuration config;
@GET public DataResponse<Team> teams( @Context UriInfo uriInfo) { return LinkRest .select(Team.class, config) .uri(uriInfo) .select(); }
@PUT @Consumes(MediaType.APPLICATION_JSON) @Path("{id}") public DataResponse<Team> update( @PathParam("id") int id, String data, @Context UriInfo uriInfo) { return LinkRest.update(Team.class, config) .uri(uriInfo) .syncAndSelect(data); }}
TeamResource.java
Demo Teams Grid
LinkRest Features
LinkRest FeaturesLinkRest protocol extensions and functionality enhancements
• LinkRestProxy
• include/exclude
• object include
• filters and sorters
• cayenneExp (JPA)
• EntityProperty (entity encoder)
• POJO encoding
• mapBy
• Multi-source
• Idempotent updates (and creates)
• Meta-data service
Security
Authorization
SecurityAuthorization
Constraints
SecurityConstraints• Underimplement HTTP methods
• Trim ORM graph of unnecessary relationships
• @ClientReadable / @ClientWritable
• Constraints
Getting Started
github.com/nhl
github.com/bootique
The Future
Q & A
#LinkRest
Further Information
Please contribute!
github.com/nhl/link-rest
github.com/nhl
@rzenetl