• Stars
    star
    175
  • Rank 218,059 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Type-safe routes for Express and Koa

typera - Type-safe routes

Build

Typera helps you build backends in a type-safe manner by leveraging io-ts and some TypeScript type inference magic. It works with both Express and Koa.

Upgrading to version 2? See the upgrading instructions.

Features of typera in a nutshell:

  • A purer approach to building your apps: Each route handler is an async function that takes a request and returns a response. Mutable req or res objects? Never again!

  • Automatically parses request inputs like route params, query params, headers and request body into typed values.

  • Infer the types of responses (status code, body, headers), allow type checking them according to your expectations.

  • Middleware are fully typed. This means that you no longer have to guess what's available in req, or whether a middleware short-circuits and returns a response. Instead, everything is type checked!

  • It's straightforward to start adding fully typed routes to an existing Express or Koa app. Old routes can be migrated gradually.

  • Built-in support for automatically generating an OpenAPI definition from your app with typera-openapi.

Typera is a really thin layer on top of Express or Koa. Most of its code is TypeScript typings, and the actual runtime stuff is minimal.

See the documentation for tutorial, examples, API reference and more!

Development

Run yarn to install dependencies.

Running the test suite

Run yarn test.

Documentation

You need Python 3 to build the docs.

python3 -m venv venv
./venv/bin/pip install mkdocs-material

Run a live reloading server for the documentation:

./venv/bin/mkdocs serve

Open http://localhost:8000/ in the browser.

Releasing

$ yarn lerna version <major|minor|patch>
$ yarn lerna publish from-git

Open https://github.com/akheron/typera/releases, edit the draft release, select the newest version tag, adjust the description as needed.

More Repositories

1

jansson

C library for encoding, decoding and manipulating JSON data
C
3,072
star
2

optics-ts

Type-safe, ergonomic, polymorphic optics for TypeScript
TypeScript
769
star
3

sqltyper

TypeScript types for raw PostgreSQL queries
TypeScript
126
star
4

cpython

**No longer updated!** CPython has moved to GitHub: https://github.com/python/cpython
Python
61
star
5

sala

Simple encrypted password storage
Rust
28
star
6

typera-openapi

Generate OpenAPI spec from typera routes
TypeScript
23
star
7

stango

Static web site generator for Python programmers
Python
23
star
8

diceware.py

Diceware passphrase generator
Python
20
star
9

multipy

Install multiple Python versions locally
Shell
19
star
10

dependabot-cron-action

Merge Dependabot pull requests in a cron schedule
TypeScript
10
star
11

cram

Git mirror of https://bitbucket.org/brodie/cram/
Python
8
star
12

skijump3-remake

Skijump International v3 (remake)
Rust
5
star
13

hashtable

A hashtable implementation
C
5
star
14

emacs-config

My emacs configuration
Emacs Lisp
4
star
15

xkb

My XKB config
4
star
16

elm-easter

Compute the date of Easter for any given year
Elm
3
star
17

purescript-httpure-extras

Common utilities for HTTPure
PureScript
3
star
18

passman

2
star
19

brainfuck

Brainfuck interpreter written in Elm
Elm
2
star
20

www.digip.org

The Stango project for my personal website
HTML
2
star
21

wings-reverse

Reversing Wings 1.40
Rust
2
star
22

git-hg

Push and pull from a Hg server using git
Shell
2
star
23

sinap

Sinap IRC bot
Python
1
star
24

microposture

A program for 2 micro:bit devices for monitoring your back posture
Python
1
star
25

jansson-debian

Debianization for Jansson
C
1
star
26

jansson-debian-pre2.0

Debianization for Jansson
Shell
1
star
27

sahko

Control electrical devices by turning GPIO pins on and off on a Raspberry Pi based on the electricity spot price
Rust
1
star