Sunday, August 19, 2018

A more RESTful future

As of the 0.2.x branch, Travetto has moved all RESTful packages towards a framework-agnostic structure.  The primary driver behind this, is to allow for alternatives to express.js to be used in applications.  Currently, koa and fastify have been added to the list of supported backends. 

Additionally, all packages that previously built upon the express module, now will build upon the rest module.  This means that Asset-Express, Auth-Express, and Express modules have been deprecated, and replaced with Asset-Rest, Auth-Rest, and Rest respectively.  The Rest module also provides an API for Request and Response objects that allows for building backend agnostic middleware.  The APIs are modeled after express, allowing for usage of the most common middleware packages (e.g. passport). 

This means that the Rest framework allows for koa and fastify to both use passport via the Request/Response API.  Also, the Swagger integration occurs at the Rest level, and so all documentation patterns still apply.

Enjoy,
- The Travetto Team

Friday, August 10, 2018

Release 0.2.0 (Alpha): A Little More Swagger

The first major update to the framework, since the alpha launch, has just been announced.  We are pleased to announce the integration of Controller and Schema documentation.  Starting with this release (0.2.0), the Controller and Schema registries will now also house documentation information (e.g. title, description, etc).  Additionally, with the Controllers, we now support enforcement of parameter (path, query) types.

As you can see, the documentation is supported via JSDoc comments, type annotations, and even directly via Decorators (SchemaBody, SchemaQuery, PathParam, Describe...).  This reinforces the paradigm of not forcing developers to repeat themselves.

Additionally, with the documentation model created, we now support the ability to take that model and generate familiar output formats.   The format we are launching with, is Swagger v2.0 (Version 3 will be supported when the swagger-codegen tools supports it).  When the @travetto/swagger module is imported, it will automatically register a /swagger.json endpoint that will return the API specification.

Not to stop short, we additionally provide the ability to generate a client, at run-time, from the swagger spec, using the swagger-codegen tool.  If configured properly, every change to a model or an endpoint will trigger a regeneration of the spec as well as the client.  This should be useful when doing full stack development, and wanting to have a typed model/client between the front end and back end.

In addition to the above there have been minor fixes and performance enhancements.

Enjoy,
- The Travetto Team