Issue #12 – Type safety end to end – Vercel on the edge

Issue #12 – Type safety end to end – Vercel on the edge

Aobakwe Kodisang
February 14, 2023
Blog cover image

Issue #12 – Type safety end to end – Vercel on the edge

<1/> End to end typesafety with tRPC

TypeScript, static typing, has been increasing in popularity in the web development world, at the time of writing this, tRPC, at TypeScript project, is the second most trending on GitHub.

End to end type safety is more of a developer experience kind of problem, it is better to detect errors pre-compilation, and during development, than at runtime. That means less time debugging, and we can take it a step further and say less time writing unit tests.


What does end to end type safety mean? It means that you have a single source of truth across your application for your types. Generally, this would come from your database schema.

Enter tRPC. How does tRPC fit in any of this? tRPC allows us to develop and consume type safe APIs, without schemas or code generation. You can write your endpoint as types and the client gets access to these types, all thanks to the power of Typescript and React Query. During development, if at any point we change our endpoint types, the client can detect these changes, thus less time trying to figure out where to handle all this. In contrast to achieve this sort of feat with GraphQL, you might end up chaining it with other libraries, however, tRPC is not a 1:1 replacement for GraphQL.

Since GraphQL is designed as a language-agnostic specification for implementing APIs, it doesn’t take full advantage of the power of a language like TypeScript

<2/> Deeper Dives

Colin McDonnell @colinhacks Building an end-to-end typesafe API — without GraphQL

<3/> The Weekly Dev

Vercel recently came out with the Edge Runtime, a runtime that is designed to be leveraged by other frameworks. The Edge Runtime is currently in the experimental phase for NextJS, with promises of fast startups and low latency, this is surely one to get excited about.

designed to help framework authors adopt edge computing and provide open-source tooling built on Web standards

This is for usage at framework level and not at application code level. When your framework is built on the Edge Runtime, at a production level, your framework gets to choose the optimal infrastructure for you.
One point to consider is that in production, Edge Runtime uses Javascript V8 Engine and not Nodejs.

If your application has some NodeJS APIs that it depends on, moving towards the Edge Runtime might not be the right move

You can go through this Getting Started to learn more:

Next.jstimneutkensNext.js 12.2Next.js 12.2 introduces stable Middleware and On-Demand ISR, experimental Edge SSR and API Routes, and more!
Edge Runtime Getting Started | Edge Runtime

<4/> Inside the console


Amazon Elastic Compute Cloud (EC2) allows you to pick and choose your virtual hardware based on your specific project requirements. You can customize everything, from the processor to the operating system.

The Elastic in EC2 refers to the virtual server’s elasticity, meaning it is entirely up or down-scaleable depending on demand. This adaptability and access to on-demand virtual hardware make it ideal for hosting cloud native & enterprise applications.

Some services exclusive to AWS are:

  • on-demand EC2 Mac instances
  • 400Gbps Ethernet networking

The AWS EC2 free tier includes 750 hours of Linux and Windows t2.micro instances each month for a year! Additionally, there are five ways to pay your instances; On-Demand, Savings Plans, Reserved Instances & Spot Instances. You can also pay for a dedicated physical server. Read more about EC2 pricing here.

<5/>Geeking it up

Microservices Data Design Patterns

Neeraj Kushwaha discusses some great data design patterns when working with microservices.

AutoRegex

A natural language processor that converts English to RegEx!

PocketBase.io

PocketBase is a single file backend built for SaaS & mobile applications. It’s open source and integrates with your favorite javascript frontend stack! Dart integration coming soon.

As seen on FOX, Digital journal, NCN, Market Watch, Bezinga and more

Scale your development team
faster with Scrums.com

Get in touch and let's get started
Book a Demo
Tick
Cost-effective
Tick
Reliable
Tick
Scalable