Typera

screenshot of Typera
express

Typera

Type-safe routes for Express and Koa

Overview

Typera is a tool that helps build backends in a type-safe manner by leveraging io-ts and TypeScript type inference magic. It works with both Express and Koa, providing a purer approach to building applications and automatically parsing request inputs into typed values. Typera simplifies the process of adding fully typed routes to an existing Express or Koa app and offers built-in support for generating an OpenAPI definition.

Features

  • Type-safe route handling: Each route handler is an async function that takes a request and returns a response, eliminating the need for mutable req or res objects.
  • Automatic parsing of request inputs: Typera automatically parses request inputs like route params, query params, headers, and request body into typed values.
  • Typed responses and middleware: Infer the types of responses, headers, and middleware, ensuring type checking according to expectations.
  • Easy migration: It's straightforward to start adding fully typed routes to an existing Express or Koa app and migrate old routes gradually.
  • Built-in OpenAPI generation: Typera offers built-in support for automatically generating an OpenAPI definition from your app.
  • Thin layer on top of Express or Koa: Most of Typera's code consists of TypeScript typings, with minimal runtime stuff.

Installation

To install Typera, follow these steps:

  1. Run yarn to install dependencies.
  2. To run the test suite, use yarn test.
  3. For documentation, ensure you have Python 3 installed and follow the instructions to build the docs.
  4. Open http://localhost:8000/ in the browser to run a live reloading server for the documentation.
  5. For releasing Typera, visit the GitHub releases page, edit the draft release, select the newest version tag, and adjust the description as needed.

Summary

In summary, Typera is a powerful tool for building type-safe backends with Express or Koa. It offers features like type-safe route handling, automatic parsing of request inputs, fully typed responses and middleware, easy migration for existing apps, OpenAPI generation support, and a minimalist approach as a thin layer on top of the chosen server framework. Its installation process is straightforward, requiring basic commands like yarn and yarn test, along with guidance on building the documentation and releasing new versions.

express
Express

Express.js is a simple Node.js framework for single, multi-page, and hybrid web applications.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.