47
LinkRest — Modern RESTful API Framework for ExtJS Apps Rouslan Zenetl, Director of App Development, NHL

SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

  • Upload
    sencha

  • View
    124

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRest — Modern RESTful API Framework for ExtJS Apps

Rouslan Zenetl, Director of App Development, NHL

Page 2: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Q & A

#LinkRest

Page 3: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

The Problem

Page 4: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

APIs

Page 5: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

APIs

Page 6: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

APIs

Page 7: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

RESTful APIs

Page 8: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl
Page 9: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

API attendants

Page 10: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

“Is It Worth It?” Toxicity

Page 11: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl
Page 12: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

The Solution

Page 13: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl
Page 14: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Skip the middleman

Page 15: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

No more API attendants

Page 16: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Win-win

Page 17: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

What is LinkRest?

Page 18: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRestWhat is it?• . . .a protocol- fully compatible with Ext.data.proxy.Rest

• . . .an implementation of the protocol- extensible

Page 19: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRest Stack

Data StorageJDBC, NoSQL, more..

Page 20: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRest Stack

ORMCayenne, POJO, more..

Data StorageJDBC, NoSQL, more..

Page 21: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRest Stack

LinkRest

ORMCayenne, POJO, more..

Data StorageJDBC, NoSQL, more..

Page 22: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRest

ORMCayenne, POJO, more..

Data StorageJDBC, NoSQL, more..

ExtJS

App

licat

ion

Clie

nt

Page 23: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

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

Page 24: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRest Stack

LinkRest

ORMCayenne, POJO, more..

Data StorageJDBC, NoSQL, more..

Page 25: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRest Coexists

LinkRest

ORMCayenne, POJO, more..

Data StorageJDBC, NoSQL, more..

Existing APIs

Page 26: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

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

Page 27: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

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..

Page 28: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Basic LinkRest

Page 29: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

# 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)

Page 30: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Demo DB Schema

Page 31: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Demo DB SchemaWe’ll use this simple database for demos today (NOT REAL DATA)

Page 32: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

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

Page 33: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Demo Teams Grid

Page 34: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

LinkRest Features

Page 35: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

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

Page 36: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Security

Page 37: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Authorization

Page 38: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

SecurityAuthorization

Page 39: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Constraints

Page 40: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

SecurityConstraints• Underimplement HTTP methods

• Trim ORM graph of unnecessary relationships

• @ClientReadable / @ClientWritable

• Constraints

Page 41: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Getting Started

Page 42: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

github.com/nhl

Page 43: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

github.com/bootique

Page 44: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

The Future

Page 45: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Q & A

#LinkRest

Page 46: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl

Further Information

Please contribute!

github.com/nhl/link-rest

github.com/nhl

@rzenetl

Page 47: SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rousland Zenetl