Repository navigation
RESTe 2.0.0 is the first release of this fork of RESTe by Jason Kneen.
RESTe has been the way a lot of Titanium and Alloy apps talk to their APIs for years: describe your endpoints once, get a method for each, and bind lists to collections that load themselves. That idea is Jason's, and it is why this fork exists. 2.0 keeps it exactly as it was (one file, no dependencies, require('reste') returns the same constructor, a 1.x config still works) and adds the things apps have ended up writing around it.
What is new
- Promises from every call, with
abort(). Callbacks still work. - Headers per instance, per endpoint and per call, resolved for each request.
- One error type: status, parsed body, headers, and what kind of failure it was (HTTP, network, timeout, cancelled, parse).
- Retries with back-off and
Retry-After, only for requests that are safe to repeat, plus idempotency keys. - Caching: ETag,
Cache-Control, stale-while-revalidate, in memory or in a persistent store. - Pagination for page and cursor APIs that keeps the server's metadata:
fetchNext(),refresh(). - Collections that update in place: the same model instances, change events only for what changed, one render per update. Model sync is scoped to the instance, so several APIs can live in one app.
- Uploads and downloads: multipart with
Ti.Bloband files, with progress. - Session reset that drops responses arriving late, in-flight de-duplication, interceptors, and a debug log that redacts credentials.
- TypeScript declarations in
reste.d.ts. - A two-file build (
reste-split-2.0.0.zip) for apps that count the milliseconds of a cold start.
The README has the full table of what changed, a migration table for the few places where 1.x behaviour is different, and the performance measurements. The complete list is in the changelog.
Install
Copy reste.js from this release into app/lib/, or install it with npm from the tag:
cd app/lib && npm install github:centrevilletech/Ti.ModernRESTe#v2.0.0const Reste = require('reste'); // the file in app/lib
const Reste = require('@centrevilletech/reste'); // the npm installChecked on
Titanium SDK 13.4.1.GA with Alloy 3.0.1, on Android and iOS, with every Backbone version Alloy offers (0.9.2, 1.1.2, 1.3.3, 1.4.0, 1.6.0). 911 tests run against the sources, the single file and the two-file build.
Thanks
To Jason Kneen for RESTe, and to everyone who contributed to it upstream. Licensed under Apache-2.0, as the original is; see NOTICE.