Type Safe APIs at the speed of light ๐Ÿš€

mion is a lightweight TypeScript-based framework designed for building Type-Safe APIs. It aims to provide a great developer experience and is ready for serverless environments. With mion, you can quickly build APIs that are type-safe, with automatic validation and serialization out of the box.

Why Another Framework?

  • There are not many frameworks that offer Type-Safe APIs and take full advantage Typescript type system.
  • Serverless applications have different requirements compared to conventional servers.
  • mion takes advantage of a new generation of tools (Deepkit) that bring types to runtime allowing automatic validation/serialization out of the box and a whole new set of possibilities.
  • Generic HTTP frameworks have a lot of baggage that is not required for modern APIs.
    Url or path params, multiple mime-types, file uploads, multipart/form-data and many other features that generic HTTP frameworks must support just make them more complicated and slow.

mion addresses these challenges by offering a lightweight and opinionated framework focused on simplicity and developer experience.

RPC "Like"

mion is designed with a Remote Procedure Call (RPC) style where functions are the primary interface and there are no abstractions over the API data.

We use the term RPC "Like" to highlight that mion does not use an RPC or custom protocol.
mion operates over HTTP yet it uses an RPC style routing.

Automatic Serialization & Validation

mion needs @deepkit/type-compiler to emit type metadata during compilation time. Then mion uses that metadata at runtime for automatic validation and serialization.

By leveraging runtime types, mion offers advanced capabilities such as type validation and serialization that typically involve using multiple frameworks or tools and lots of extra code or extra boilerplate to be manually written by developers.

If you want to read more about TypeScript runtime types and the different approaches solving this problem, you can check the typescript-needs-types repo.

Fast

We have prioritized and tracked performance during the development of the framework, we even discarded features or experiments when we observed a performance degradation. Our goal is to have similar performance to fastify which we consider the gold standard in node.js frameworks!

Check out the Benchmarks page for more info!

We know, benchmarks are just benchmarks...
But if you don't keep performance in check you end up like Internet Explorer!

Routing

mion's router is lightweight and fast. Unlike traditional routers, the HTTP method is not relevant, there are no parameters in the URL, and data is sent and received in JSON format via the request body or headers. mion's router leverages a simple in-memory map for route lookup, making it extremely fast.

Apis are composed of Routes and Hooks. Routes are methods that can be called remotely from the client and have a specific URL, while hooks are auxiliary methods that get executed before or after a route.

To learn more about the router, refer to the Router Documentation.